x,y=map(int,input().split()) a,b=map(int,input().split()) ans=max(x,y) if x==y and a==b: ans+=1 print(ans)