use std::io::*; fn main() { let mut s: String = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let mut itr = s.trim().split_whitespace(); let n: usize = itr.next().unwrap().parse().unwrap(); let _: usize = itr.next().unwrap().parse().unwrap(); let mut col: Vec> = vec![vec![]; n]; for _ in 0..n { let b = itr.next().unwrap().parse::().unwrap() - 1; let c = itr.next().unwrap().parse::().unwrap() - 1; col[c].push(b); } let mut ans = 0; for i in 0..n { if col[i].len() == 0 { continue; } col[i].sort(); col[i].dedup(); ans += col[i].len() - 1; } println!("{}", ans); }