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 { col[i].sort(); let mut j = 0; let l = col[i].len(); let mut tmp = 0; while j < l { let mut k = 1; while j + k < l && col[i][j + k] == col[i][j] { k += 1; } tmp = std::cmp::max(tmp, k); j += k; } ans += l - tmp; } println!("{}", ans); }