use std::collections::{HashMap, HashSet}; fn g() -> Vec { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.split_whitespace().flat_map(str::parse).collect() } fn main() { let n = g(); let mut c = g(); let mut h = HashMap::<_, HashSet<_>>::new(); let mut a = 0; for _ in 0..n[1] { let v = g(); if c[v[0] - 1] != c[v[1] - 1] { continue; } let s = h.entry(v[0]).or_insert(HashSet::new()); a += (s.insert(v[0]) || s.insert(v[1])) as i32; } c.sort(); println!( "{}", c.windows(2).fold(0, |t, x| t + (x[0] == x[1]) as i32) - a ) }