x1,y1 = map(int,raw_input().split()) x2,y2 = map(int,raw_input().split()) if x1 != y1: print max(x1,y1) else: if x2 < x1 and x2 == y2: print (x1 + 1) else: print x1