import numpy as np x, y = list(map(int, input().split(' '))) x2, y2 = list(map(int, input().split(' '))) if x == y and x2 == y2 and np.sign(x) == np.sign(x2) and np.sign(y) == np.sign(y2): print(x + 1) else: print(max([x, y]))