fn main(){ let n: usize = read(); let mut adl: Vec> = vec![Vec::new();n+1]; for _ in 1 .. n { let ab: Vec = read_vec(); let a = ab[0]; let b = ab[1]; adl[a].push(b); adl[b].push(a); } let mut ans: usize = 0; for i in 1 .. n+1 { if adl[i].len() > 2 { ans += adl[i].len() - 2; } } println!("{}", ans); } fn read() -> T where T: std::str::FromStr, T::Err: std::fmt::Debug { let mut buf = String::new(); std::io::stdin().read_line(&mut buf).expect("failed to read"); buf.trim().parse().unwrap() } fn read_vec() -> Vec where T: std::str::FromStr, T::Err: std::fmt::Debug { let mut buf = String::new(); std::io::stdin().read_line(&mut buf).expect("failed to read"); buf.split_whitespace().map(|e| e.parse().unwrap()).collect() }