def main(): x, y = map(int, input().split()) x2, y2 = map(int, input().split()) straight = abs(x-y) slanted = min(x, y) if straight == 0 and x2 == y2 and x > x2: print(slanted + 1) else: print(straight + slanted) if __name__ == "__main__": main()