#[macro_export] macro_rules! setup { { mut $input:ident: SplitWhitespace $(,)? } => { use std::io::Read; let mut buf = String::new(); std::io::stdin().read_to_string(&mut buf).ok(); let mut $input = buf.split_whitespace(); }; } #[macro_export] macro_rules! parse_next { ($str_iter:expr) => { $str_iter.next().unwrap().parse().ok().unwrap() }; } #[allow(unused_imports)] use std::collections::{HashMap, HashSet, VecDeque}; fn main() { setup! { mut input: SplitWhitespace }; let a: usize = parse_next!(input); let b: usize = parse_next!(input); let c: usize = parse_next!(input); let d: usize = parse_next!(input); let ans = (|| { let mut count = 0; for i in a..=b { if c <= i && i <= d { count += 1; } } (b - a + 1) * (d - c + 1) - count })(); println!("{}", ans); }