n, m = map(int, input().split()) G = [set() for _ in range(n)] for i in range(n): b, c = map(int, input().split()) b -= 1 c -= 1 G[c].add(b) t = [] for g in G: t.append(len(g)) res = 0 for tt in t: if tt > 0: res += tt-1 print(res)