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