fn main() { let s = { let mut s = String::new(); std::io::stdin().read_line(&mut s).unwrap(); s.trim_right().to_owned() }; let vec: Vec = s.split(" ").map(|s| s.parse().unwrap()).collect(); let (amin, amax) = (vec[0], vec[1]); let (bmin, bmax) = (vec[2], vec[3]); let mut count = 0; for i in amin..(amax+1) { for j in bmin..(bmax+1) { if i != j { count += 1; } } } println!("{:?}", count); }