Vasiliy spent his vacation in a sanatorium, came back and found that he completely forgot details of his vacation! 

Every day there was a breakfast, a dinner and a supper in a dining room of the sanatorium (of course, in this order). The only thing that Vasiliy has now is a card from the dining room contaning notes how many times he had a breakfast, a dinner and a supper (thus, the card contains three integers). Vasiliy could sometimes have missed some meal, for example, he could have had a breakfast and a supper, but a dinner, or, probably, at some days he haven't been at the dining room at all.

Vasiliy doesn't remember what was the time of the day when he arrived to sanatorium (before breakfast, before dinner, before supper or after supper), and the time when he left it (before breakfast, before dinner, before supper or after supper). So he considers any of these options. After Vasiliy arrived to the sanatorium, he was there all the time until he left. Please note, that it's possible that Vasiliy left the sanatorium on the same day he arrived.

According to the notes in the card, help Vasiliy determine the minimum number of meals in the dining room that he could have missed. We shouldn't count as missed meals on the arrival day before Vasiliy's arrival and meals on the departure day after he left.


-----Input-----

The only line contains three integers b, d and s (0 ≤ b, d, s ≤ 10^18,  b + d + s ≥ 1) — the number of breakfasts, dinners and suppers which Vasiliy had during his vacation in the sanatorium. 


-----Output-----

Print single integer — the minimum possible number of meals which Vasiliy could have missed during his vacation. 


-----Examples-----
Input
3 2 1

Output
1


Input
1 0 0

Output
0


Input
1 1 1

Output
0


Input
1000000000000000000 0 1000000000000000000

Output
999999999999999999





-----Note-----

In the first sample, Vasiliy could have missed one supper, for example, in case he have arrived before breakfast, have been in the sanatorium for two days (including the day of arrival) and then have left after breakfast on the third day. 

In the second sample, Vasiliy could have arrived before breakfast, have had it, and immediately have left the sanatorium, not missing any meal.

In the third sample, Vasiliy could have been in the sanatorium for one day, not missing any meal.

Difficulty: interview

Starter code:

Solutions:
a = list(map(int, input().split()))
m = max(a)

ans = 0
for i in range(3):
    if a[i] < m - 1:
        ans += (m - 1) - a[i]
        a[i] = m - 1

print(ans)


def c(ans, b ,d, s):
	return(min(ans, 3 * max(b, d, s) - b - d - s))
b, d, s = list(map(int, input().split()))
ans = 10**19
m = min(b, d, s)
b = b - m
d = d - m
s = s - m
if b > 0:
	b -= 1
	ans = c(ans, b, d, s)
	b += 1
if d > 0:
	d -= 1
	ans = c(ans, b, d, s)
	d += 1
if s > 0:
	s -= 1
	ans = c(ans, b, d, s)
	s += 1
if b * d > 0:
	b -= 1
	d -= 1
	ans = c(ans, b, d, s)
	b += 1
	d += 1
if b * s > 0:
	b -= 1
	s -= 1
	ans = c(ans, b, d, s)
	b += 1
	s += 1
if s * d > 0:
	s -= 1
	d -= 1
	ans = c(ans, b, d, s)
	s += 1
	d += 1
if b + d + s == 0:
	ans = 0
print(ans)


b, d, s = list(map(int, input().split()))
har = [max(s - 1, d - 1, b), max(d, b - 1, s - 1), max(d - 1, s, b - 1)]
print(har[0] - b + har[1] - d + har[2] - s)



b,d,s = list(map(int, input().split()))

r = 0
if b == s and d == s:
    print(0)
elif b >= s and b >= d:
    print(max(0,abs(b-d)-1)+max(abs(b-s)-1,0))
elif s >= b and s >= d:
    print(max(0,abs(s-b)-1)+max(abs(s-d)-1,0))
elif d >= s and d >= b:
    print(max(0,abs(d-s)-1)+max(abs(d-b)-1,0))
    


x = input().split()
a = int(x[0])
b = int(x[1])
c = int(x[2])

mexx = max(max(a,b), c)
mexx -= 1
ans = 0
ans += max(0, mexx-a)
ans += max(0, mexx-b);
ans += max(0, mexx-c);
print(ans)

B,L,S = ( int(x) for x in input().split() )
K = max(B,L,S)
cost = 0
for meal in [B,L,S]:
	if meal != K:
		cost += K-1 - meal

print(cost) 

def get(x, y, z):
    return max(x, y, z) * 3 - x - y - z


a, b, c = list(map(int, input().split()))
ans = min(get(a, b, c),
          get(a - 1, b, c),
          get(a - 1, b - 1, c),
          get(a, b - 1, c),
          get(a, b - 1, c - 1),
          get(a, b, c - 1),
          get(a - 1, b, c - 1),
          )
print(ans)


a = list(map(int, input().split()))
a.sort()
a[2] -= 1
ans = (a[2] - a[1] > 0) * (a[2] - a[1]) + (a[2] - a[0] > 0) * (a[2] - a[0])
print(ans)

mas = list(map(int, input().split()))
mas.sort()
ans = 0
if mas[2] != mas[1]:
    ans += mas[2] - mas[1] - 1
    mas[1] = mas[2] - 1
if mas[0] != mas[1]:
    if mas[1] == mas[2]:
        ans += mas[1] - mas[0] - 1
    else:
        ans += mas[1] - mas[0]
    mas[0] = mas[1]
print(ans)

b, d, s = map(int, input().split())
# b, d, s = 3, 2, 1

def mins(a, b, c):
	if min([a, b, c]) == a:
		return a, min(b, c)
	if min([a, b, c]) == b:
		return b, min(a, c)
	if min([a, b, c]) == c:
		return c, min(a, b)

ma = max([b, d, s])
mi1, mi2 = mins(b, d, s)

a1 = max(0, ma - 1 - mi1)
a2 = max(0, ma - 1 - mi2)
print(a1 + a2)

def fun(b,d,s):
    if b == d == s:
        return 0
    
    if b > d and b > s:
        return (b-1-d)+(b-1-s)
    if d > b and d > s:
        return (d-1-b)+(d-1-s)
    if s > b and s > d:
        return (s-1-b)+(s-1-d)
    if b == d and b > s:
        return (b-1-s)
    if b == s and b > d:
        return (b-1-d)
    if d == s and d > b:
        return (d-1-b)
    return 0
    
b,d,s = map(int, input().split())
ans = fun(b,d,s)
print(ans)

b, d, s = map(int, input().split())
if b >= d and b >= s:
    ans = max(0, b - d - 1) + max(0, b - s - 1)
elif d >= s and d >= b:
    ans = max(0, d - s - 1) + max(0, d - b - 1)
else:
    ans = max(0, s - d - 1) + max(0, s - b - 1)
print(ans)

a, b, c = map(int, input().split())
ans = 0
x, y, z = max(a, b, c), (a + b + c) - (max(a, b, c) + min(a, b, c)), min(a, b, c)
if x > y:
    ans += x - y - 1
if x > z:
    ans += x - z - 1
print(ans)

3.5
mas=[int(x) for x in input().split()]
mas.sort()

p=0
k=mas[2]-1

if mas[1]<k:
    p+=k-mas[1]
if mas[0]<k:
    p+=k-mas[0]
    
print(p)

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

l = sorted(l, reverse=True)

min_result = 10000000000000000000000000000

delts = [(1,0,0), (1,1,0), (0,0,1), (0,1,1), (0,0,0)]

for delt in delts:
    a = []
    for i in range(3):
        a.append(l[i] + delt[i])
    a = sorted(a, reverse=True)
    min_result = min(min_result, a[0] - a[1] + a[0] - a[2])

print(min_result)


def __starting_point():
    arr = [int(ch) for ch in input().split(' ')]

    a = arr[0]
    b = arr[1]
    c = arr[2]

    if a == b and  a == c:
        print('0')
        return

    maximum = max(a, b, c)
    res = True
    for i in arr:
        if i != maximum or i != (maximum - 1):
            res = False
    if res:
        print('0')
        return

    adding = 0
    for i in arr:
        if i == maximum:
            continue
        else:
            adding += maximum - i - 1

    print(adding)
__starting_point()

b, d, s = list(map(int,input().split()))

if b > d and b > s:
    print((b-1)-d+(b-1)-s)
elif d > b and d > s:
    print((d-1)-b+(d-1)-s)
elif s > b and s > d:
    print((s-1)-b+(s-1)-d)
elif b == d and b > s:
    print(max(0, (b-1)-s))
elif d == s and d > b:
    print(max(0, (d-1)-b))
elif b == s and b > d:
    print(max(0, (b-1)-d))
else:
    print(0)


def do():
    b,d,s = list(map(int,input().split()))
    if (b == d == s):
        return 0
    elif (b == d and b > s):
        return b - s - 1
    elif (b == d and b < s):
        return 2*(s - b - 1)
    elif (b == s and b > d):
        return b - d - 1
    elif (b == s and b < d):
        return 2*(d - b - 1)
    elif (d == s and d > b):
        return d - b - 1
    elif (d == s and d < b):
        return 2*(b - d - 1)
    else: # b d s are all different
        if (b > d and b > s): # b = max
            if (d > s):
                return 2*(b - 1 - d) + d - s
            else:
                return 2*(b - 1 - s) + s - d
        elif (d > b and d > s): # d = max
            if (b > s):
                return 2*(d - 1 - b) + b - s
            else:
                return 2*(d - 1 - s) + s - b
        else: # s = max
            if (b > d):
                return 2*(s - 1 - b) + b - d
            else:
                return 2*(s - 1 - d) + d - b

rs = do()
print(rs)


import sys

fin = sys.stdin
fout = sys.stdout

b, s, d = list(map(int, fin.readline().split()))

wars = []


def nextDelta(dB, dS, dD):
    tempB = b + dB
    tempS = s + dS
    tempD = d + dD
    m = max(tempB, tempS, tempD)
    rz = 0
    rz += abs(m - tempB)
    rz += abs(m - tempS)
    rz += abs(m - tempD)
    wars.append(abs(rz))


nextDelta(1, 0, 1)
nextDelta(1, 1, 1)
nextDelta(2, 1, 1)
nextDelta(2, 2, 1)
nextDelta(1, 2, 1)
nextDelta(1, 1, 1)
nextDelta(2, 2, 2)
nextDelta(1, 2, 2)
nextDelta(1, 1, 2)
nextDelta(0, 0, 0)
fout.write(str(min(wars)))


from collections import defaultdict
import sys, os, math

def __starting_point():
    #n, m = list(map(int, input().split()))
    b, d, s = map(int, input().split())
    ans = 0
    if b > d and b > s:
        ans = (b - 1) * 3 + 1 - d - b - s
    elif d > b and d > s:
        ans = (d - 2) * 3 + 4 - d - b - s
    elif s > d and s > b:
        ans = (s - 1) * 3 + 1 - d - b - s
    elif s == d == b:
        ans = 0
    elif d == b:
        ans = (b - 1) * 3 + 2 - d - b - s
    elif b == s:
        ans = (b - 1) * 3 + 2 - d - b - s
    else:
        ans = (d - 1) * 3 + 2 - d - b - s
    print(ans)
__starting_point()

b,d,s=list(map(int,input().split()))
a1,a2,a3,a4=0,0,0,0


if max(b,s,d)==b:
    if d<b-1 and s!=max(b,s,d):
        a1+=b-1-d
    if d<b-1 and s==max(b,s,d):
        a1+=b-d
    if s<b-1:
        a1+=b-1-s
elif max(b,s,d)==d:
    a1+=d-b
    if s<d-1:
        a1+=d-1-s
elif max(b,s,d)==s:
    a1+=s-d
    a1+=s-b
    
b1,d1,s1=d,s,b
if max(b1,s1,d1)==b1:
    if d1<b1-1 and s1!=max(b1,s1,d1):
        a2+=b1-1-d1
    if d1<b1-1 and s1==max(b1,s1,d1):
        a2+=b1-d1
    if s1<b1-1:
        a2+=b1-1-s1
elif max(b1,s1,d1)==d1:
    a2+=d1-b1
    if s1<d1-1:
        a2+=d1-1-s1
elif max(b1,s1,d1)==s1:
    a2+=s1-d1
    a2+=s1-b1
    
b,d,s=s,b,d
if max(b,s,d)==b:
    if d<b-1 and s!=max(b,s,d):
        a3+=b-1-d
    if d<b-1 and s==max(b,s,d):
        a3+=b-d
    if s<b-1:
        a3+=b-1-s
elif max(b,s,d)==d:
    a3+=d-b
    if s<d-1:
        a3+=d-1-s
elif max(b,s,d)==s:
    a3+=s-d
    a3+=s-b
print(min(a1,a2,a3))


def f(a, b, c):
    m = min(a, b, c)
    a, b, c = a - m, b - m, c - m
    if a == b and a == c: return 0
    if a == b:
        if abs(a - c) == 1: return 0
        elif c > a: return (c - a - 1) * 2
        else: return a - c - 1
    if a == c:
        if abs(a - b) == 1: return 0
        elif b > a: return (b - a - 1) * 2
        else: return a - b - 1
    if b == c:
        if abs(a - b) == 1: return 0
        elif a > b: return (a - b - 1) * 2
        else: return b - a - 1

    m = min(a, b, c)
    n = min(max(a, b), max(b, c), max(a, c))
    if a == m: a = n
    elif b == m: b = n
    else: c = n
    return n + f(a, b, c)

print(f(*[int(i) for i in input().split()]))


b, l, d = map(int, input().split())

m = max(b, l, d)
x = m-1
missing = 0
if x-b > 0:
    missing += x-b
if x-l > 0:
    missing += x-l
if x-d > 0:
    missing += x-d

print(missing)

a, b, c = list(map(int, input().split()))
x = max(a, b, c)
a = x - a
b = x - b
c = x - c
if (a > 0 and b > 0) or (a > 0 and c > 0) or (b > 0 and c > 0):
    print(a + b + c - 2)
elif a > 0 or b > 0 or c > 0:
    print(a + b + c - 1)
else:
    print(a + b + c)

tr = list(map(int, input().split()))
k = 0

tr.sort()

for i in range(2):
	if (tr[2] - 1) > tr[i]:
		 k += ((tr[2] - 1) - tr[i])

print(k)