lis = list(map(int,input().split()))

cou = 0

lis.sort()

while lis[2] - lis[0] > 1:

    lis[0] +=2

    cou += 1

    lis.sort()

if lis[0] == lis[1] and lis[1] == lis[2]:

    print(cou)

elif lis[1] == lis[2]:

    print((cou + 2))

else:

    print((cou + 1))
import math

lis = list(map(int,input().split()))

lis.sort()

ans = 0

while True:

    if lis[0] == lis[2]:

        print(ans)

        exit()

    if lis[0] == lis[1]:

        lis[0] += 1

        lis[1] += 1

    else:

        lis[0] += 2

    ans += 1

    lis.sort()
lis = list(map(int, input().split()))
cou = 0
lis.sort()
while lis[2] - lis[0] > 1:
    lis[0] += 2
    cou += 1
    lis.sort()
if lis[0] == lis[1] and lis[1] == lis[2]:
    print(cou)
elif lis[1] == lis[2]:
    print((cou + 2))
else:
    print((cou + 1))

import math

lis = list(map(int, input().split()))
lis.sort()
ans = 0
while True:
    if lis[0] == lis[2]:
        print(ans)
        exit()
    if lis[0] == lis[1]:
        lis[0] += 1
        lis[1] += 1
    else:
        lis[0] += 2
    ans += 1
    lis.sort()

+import math + -cou = 0 -while lis[2] - lis[0] > 1: -    lis[0] += 2 -    cou += 1 +ans = 0 +while True: +    if lis[0] == lis[2]: +        print(ans) +        exit() +    if lis[0] == lis[1]: +        lis[0] += 1 +        lis[1] += 1 +    else: +        lis[0] += 2 +    ans += 1 -if lis[0] == lis[1] and lis[1] == lis[2]: -    print(cou) -elif lis[1] == lis[2]: -    print((cou + 2)) -else: -    print((cou + 1))