N,M = map(int,input().split()) color = [set() for _ in range(N+1)] for i in range(N): b,c = map(int,input().split()) color[c].add(b) ans = 0 for i in range(1,N+1): if color[i]: ans += len(color[i]) - 1 print(ans)