x,y = map(int,raw_input().split()) a,b = map(int,raw_input().split()) if x == y and a == b and x > a: print x+1 else: print max(x,y)