Doritos in graph

0

0 votes
Problem

Tom is always hungry. In a graph theory class, he suddenly starts thinking of doritos (Triangular chips) which reminds him of triangles. This time he is wondering to count such triangles in an undirected graph.
A triangle in a graph is considered to be a loop formed by 3 edges.

Input
The first line contains two integers N and M as input denoting total number of nodes and total number of edges in the graph.
The next M lines contain a pair of integers u and v denoting that there is a bidirectional edge between the nodes u and v in the graph.

Output
In the output you need to print the number of triangles (doritos accoring to Tom) in the graph.

Constraints
1N1041M2×104
The graph will not be having multiple edges,

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

There is only 1 triangle 1>2>3>1 in the graph

Editor Image

?