import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); HashMap> counts = new HashMap<>(); for (int i = 0; i < n; i++) { int b = sc.nextInt(); int c = sc.nextInt(); if (!counts.containsKey(c)) { counts.put(c, new HashSet<>()); } counts.get(c).add(b); } int ans = 0; for (HashSet set : counts.values()) { ans += set.size() - 1; } System.out.println(ans); } }