x,y=map(int,raw_input().split()) x2,y2=map(int,raw_input().split()) if abs(x)==abs(y) and abs(x2)==abs(y2) and x/y==x2/y2 and x*x2>0: print max(x,y)+1 else: print max(x,y)