x1, y1 = map(int,input().split()) x2, y2 = map(int,input().split()) ans = max(x1,y1) if x2 == y2 and x1 == y1 and x1 > x2: ans += 1 print(ans)