x, y = gets.split.map(&:to_i) x2, y2 = gets.split.map(&:to_i) ans = if x == y and x2 == y2 and x2 < x x + 1 else [x, y].max end puts ans