X, Y = gets.split.map(&:to_i).map(&:abs) X2, Y2 = gets.split.map(&:to_i).map(&:abs) ans = [X, Y].max ans += 1 if X == Y && X2 == Y2 && X2 < X puts ans