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