x,y = map(int, input().split()) x2,y2 = map(int, input().split()) if x != y: print(max(x, y)) else: if x2 == y2: print(x+1) else: print(x)