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(); if x2 < x && y2 < y && x2 == y2 && x == y { println!("{}", std::cmp::max(x, y) + 1); } else { println!("{}", std::cmp::max(x, y)); } }