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