#[allow(unused_macros)] macro_rules! read { ([$t:ty] ; $n:expr) => ((0..$n).map(|_| read!([$t])).collect::>()); ($($t:ty),+ ; $n:expr) => ((0..$n).map(|_| read!($($t),+)).collect::>()); ([$t:ty]) => (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::>()); ($t:ty) => (rl().parse::<$t>().unwrap()); ($($t:ty),*) => {{ let buf = rl(); let mut w = buf.split_whitespace(); ($(w.next().unwrap().parse::<$t>().unwrap()),*) }}; } #[allow(dead_code)] fn rl() -> String { let mut buf = String::new(); std::io::stdin().read_line(&mut buf).unwrap(); buf.trim_end().to_owned() } fn main() { let (_n, x) = read!(usize, usize); let mut a = read!([usize]); a.sort(); let mut cnt = 0; let mut r_max = a.len()-1; let mut half = 0; for l in 0..a.len()-1 { if a[l] + a[l] == x { half += 1; } for r in l+1..=r_max { match (a[l] + a[r]).cmp(&x) { std::cmp::Ordering::Equal => { cnt += 2; } std::cmp::Ordering::Greater => { r_max = r; break; } _ => {} } } } println!("{}", cnt + half); }