#coding: utf-8 ##yuki_208 x,y=map(int,raw_input().split()) x2,y2=map(int,raw_input().split()) res=max(x,y) if x==y and x2==y2 and x>x2: res=max(x,y)+1 print res