import time
import math

class Graph:

    def __init__(self, n):  # create a graph with no edges
        self.size = n
        self.edges = [[] for i in range(n)]
        self.triangles = 0

    def addedge(self, inode1, inode2):
        self.edges[inode1].append(inode2)
        self.edges[inode2].append(inode1)

    def print(self):
        for n, neighs in enumerate(self.edges):
            print(str(n) + "__", neighs)
        print("------------------------------------------------")

    def countTrianglesAtNode(self, n1):
        # avoid discovering each triangle more times
        # consider only node triples (n1, n2, n3) where n1 < n2 < n3.
        for i_n1 in range(len(self.edges[n1])):
            if self.edges[n1][i_n1] < n1: continue # skip nodes lower than n1
            n2 = self.edges[n1][i_n1]
            # now, n1 and n2 are end nodes of an edge
            # each common neighbour n3 closes a triangle (n1, n2, n3)
            # scan simultaneously neighbours of nodes n1 and n2
            # exploit the fact that the neighbours are sorted
            # by their label in each adjacency list
            # ......
            i_n1 += 1     # index of the first possible triangle candidate neighbour of n1
            i_n2 = 0      # index to adjacency list of node n2
            while i_n2 < len(self.edges[n2]) and self.edges[n2][i_n2] < n2:
                i_n2 += 1   # skip nodes lower than n2
            if i_n2 >= len(self.edges[n2]): continue
            # simultaneous scan:
            while i_n1 < len(self.edges[n1]) and i_n2 < len(self.edges[n2]):
                # common neighbour?
                if self.edges[n1][i_n1] == self.edges[n2][i_n2]:
                    self.triangles += 1
                    i_n1 += 1
                    i_n2 += 1
                # continue simultaneous scan
                elif self.edges[n1][i_n1] < self.edges[n2][i_n2]:
                    i_n1 += 1
                else:
                    i_n2 += 1

    def countTriangles(self):
        for n in range(self.size):
            self.countTrianglesAtNode(n)

    def loadFromInput(self):
        self.size, E = map(int, input().split())
        self.edges = [[] for i in range(self.size)]
        self.triangles = 0
        for i in range(E):
            n1, n2 = map(int, input().split())
            self.addedge(n1, n2)
        for i in range(self.size):
            self.edges[i].sort()

# ............................................................................
#                              M A I N
# ............................................................................

time1 = time.time()

g = Graph(0)
g.loadFromInput()
time2 = time.time()
#g.print()
g.countTriangles()
time3 = time.time()

print(g.triangles)
# print("time read       %6d ms" % int(math.floor((time2 - time1) * 1000)) )
# print("time count      %6d ms" % int(math.floor((time3 - time2) * 1000)) )
# print("time total      %6d ms" % int(math.floor((time3 - time1) * 1000)) )









