x,y = map(int,raw_input().split(" ")) x2,y2 = map(int,raw_input().split(" ")) ans = 0 if x == y: if x2 == y2: ans = x + 1 else: ans = x else: ans = max(x,y) print ans