X, Y = map(int, input().split()) X2, Y2 = map(int, input().split()) if X == Y > X2 == Y2: print(X + 1) else: print(max(X, Y))