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