use std::collections::BTreeMap; fn main() { let mut nm = String::new(); std::io::stdin().read_line(&mut nm).ok(); let nm: Vec = nm.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let n = nm[0]; let m = nm[1]; let mut a = String::new(); std::io::stdin().read_line(&mut a).ok(); let a: Vec = a.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); if m == 1 { println!("1"); return; } let mut mapping = BTreeMap::new(); for &v in a.iter() { *mapping.entry(v%m).or_insert(0usize) += 1; } let mut result = 0usize; for (&key, cnt) in mapping.iter() { let other = (m - key) % m; if other == key { result += 1; continue; } if other < key && mapping.contains_key(&other) { continue; } let othercnt = *mapping.get(&other).unwrap_or(&0usize); result += cnt.max(&othercnt); } println!("{}", result); }