gx,gy=map(int,raw_input().split()) px,py=map(int,raw_input().split()) t=max(gx,gy) if px==py and gx==gy and px0: t+=1 print t