from collections import defaultdict dic = defaultdict(set) N, M = map(int, input().split()) BC = [list(map(int, input().split())) for _ in range(N)] for b, c in BC: dic[c].add(b) ans = 0 for k, v in dic.items(): ans += len(v) - 1 print(ans)