numbers = list(input().split(" "))
num1 = int(numbers[0])
num2 = int(numbers[1])
num3 = num1 + num2

output = 0

while True:
    nums = num1 + num2 + num3
    avarge = nums / 3
    median = nums - min(num1, num2, num3) - max(num1, num2, num3)

    if avarge <= median:
        output = num3
    elif avarge > median:
        break

    num3 += 1

print(output)