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