use std::io::*; fn main() { let mut s: String = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let mut itr = s.trim().split_whitespace(); let x: i64 = itr.next().unwrap().parse().unwrap(); let y: i64 = itr.next().unwrap().parse().unwrap(); let x2: i64 = itr.next().unwrap().parse().unwrap(); let y2: i64 = itr.next().unwrap().parse().unwrap(); let mut ans = 0; if x2 < x && y2 < y && x2 == y2 { ans = x2 + 2; let dx = x - (x2 + 1); let dy = y - (y2 + 1); ans += std::cmp::max(dx, dy); } else { ans += std::cmp::max(x, y); } println!("{}", ans); }