Problem:
 Score : 300 points    Problem Statement You are given three integers A , B and C . Find the minimum number of operations required to make A , B and C all equal by repeatedly performing the following two kinds of operations in any order:   Choose two among A , B and C , then increase both by 1 .  Choose one among A , B and C , then increase it by 2 .   It can be proved that we can always make A , B and C all equal by repeatedly performing these operations.      Constraints  0 \leq A,B,C \leq 50  All values in input are integers.         Input Input is given from Standard Input in the following format:  A  B  C       Output Print the minimum number of operations required to make A , B and C all equal.        Sample Input 1 2 5 4      Sample Output 1 2  We can make A , B and C all equal by the following operations:   Increase A and C by 1 . Now, A , B , C are 3 , 5 , 5 , respectively.  Increase A by 2 . Now, A , B , C are 5 , 5 , 5 , respectively.        Sample Input 2 2 6 3      Sample Output 2 5       Sample Input 3 31 41 5      Sample Output 3 23

Solution (Python):
X = list(map(int,input().split()))
X.sort()
b = X[1]-X[0]
c = X[2]-X[0]
ans = 0
if b%2==1 and c%2==1:
  b += 1
  c += 1
  ans += 1
elif b%2==1 and c%2==0:
  b += -1
  ans += 1
elif b%2==0 and c%2==1:
  c += -1
  ans += 1
ans += (c + c - b)//2
print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
a=list(map(int,input().split()))
a.sort()
A=a[0]
B=a[1]
C=a[2]
cnt=0
while A<B:
    A+=2
    cnt+=1
if A!=B:
    B+=1
    C+=1
    cnt+=1
while A<C:
    A+=1
    cnt+=1
print(cnt)

Solution (Python):

A, B, C = map(int, input().split())

L = sorted([A, B, C])

cnt1 = L[2] - L[1]
diff = L[2] - (L[0] + cnt1)

if diff % 2 == 0:
  cnt2 = (L[2]-(L[0]+cnt1)) // 2
  print(cnt1 + cnt2)
else:
  cnt2 = (L[2] + 1 - (L[0] + cnt1)) // 2
  print(cnt1+cnt2+1)

Solution (Python):
from sys import stdin

if __name__ == "__main__":
  l = [int(i) for i in stdin.readline().split(' ')]
  l = sorted(l)
  if l[0]%2 == l[1]%2:
    ex = 0
  else:
    ex = 2
  print((l[-1]*2 - (l[0] + l[1]))//2 + ex)

Solution (Python):
a,b,c=map(int,input().split())
n=2*max(a,b,c)-(a+b+c-max(a,b,c))
if n%2==0:
    print(n//2)
else:
    n+=1
    print((n//2+1))

Solution (Python):
abc=list(map(int,input().split()))
M=max(abc)
S=sum(abc)
if M*3%2==S%2:
    print((M*3-S)//2)
else:
    print(((M+1)*3-S)//2)

Solution (Python):
abc=list(map(int,input().split()))
ans=0
while min(abc)*3!=sum(abc):
    ans+=1
    abc.sort()
    sa=abc[2]-abc[0]
    if sa>=2:
        abc[0]+=2
    elif sa==1:
        abc[0]+=1
        abc[1]+=1
print(ans)

Solution (Python):
As = list(map(int, input().split()))
"""
1,1は偶奇の調整
偶奇が一致したら
2であとは行ける
"""
sAs = sorted(As, reverse=True)
amari = [a%2 for a in As]
amari_a  = sorted([(a%2,a) for a in As])
if sum(amari) == 0 or sum(amari) == 3:
    ans = (2*sAs[0] - sAs[1] - sAs[2])//2
    print(ans)
elif sum(amari) == 1:
    
    a1 = amari_a[0][1] + 1
    b1 = amari_a[1][1] + 1
    c1 = amari_a[2][1] 
    sAs = sorted([a1,b1,c1],reverse=True)
    ans = (2*sAs[0] - sAs[1] - sAs[2])//2
    print(ans+1)
else:
    
    a1 = amari_a[1][1] + 1
    b1 = amari_a[2][1] + 1
    c1 = amari_a[0][1] 
    sAs = sorted([a1,b1,c1],reverse=True)
    ans = (2*sAs[0] - sAs[1] - sAs[2])//2
    print(ans+1)

Solution (Python):
a, b, c = map(int, input().split())
answer = 0
while not (a == b == c):
    a, b, c = sorted([ a, b, c ])
    if a + 2 <= c:
        a += 2
    else:
        a += 1
        b += 1
    answer += 1
print(answer)

Solution (Python):
a,b,c=map(int,input().split())

l=[a,b,c]
l.sort(reverse=True)
x_max=l[0]
x_mid=l[1]
x_min=l[2]
count=0
count+=l[0]-l[1]
dif=l[0]-(l[2]+count)
if dif%2==0:
    count+=dif//2
else:
    count+=dif//2+2
print(count)

Solution (Python):
A,B,C=map(int,input().split())
tmp=sorted([A,B,C])
sa=tmp[2]-tmp[1]
cnt=sa
tmp[1]=tmp[2]
tmp[0]+=sa
sa2=(tmp[1]-tmp[0])//2
cnt+=sa2
tmp[0]+=sa2*2
if tmp[0]!=tmp[1]:
    cnt+=2

print(cnt)

Solution (Python):
a = list(map(int, input().split()))
k = (max(a)*3-sum(a))%2
print(((max(a)+k)*3-sum(a))//2)

Solution (Python):
import math
num = list(map(int,input().split()))
num.sort()

tmp = max(num) * 3 - sum(num)

for i in range(2):
    num[i] %= 2

if num[0] == num[1]:
    print(math.ceil(tmp/2))
else:
    print(math.ceil(tmp/2)+1)

Solution (Python):

import sys


def solve(A: int, B: int, C: int):
    max_abc= max(A,B,C)

    dif = 3*max_abc-A-B-C
    if dif%2 == 0:
        print(dif//2)
    else:
        print((3*(max_abc+1)-A-B-C)//2)
    
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  
    B = int(next(tokens))  
    C = int(next(tokens))  
    solve(A, B, C)

if __name__ == '__main__':
    main()

Solution (Python):

import sys


def solve(A: int, B: int, C: int):
    answer = 0
    max_abc= max(A,B,C)

    answer += (max_abc-A)//2
    A = max_abc-int((max_abc-A)%2 != 0)
    answer += (max_abc-B)//2
    B = max_abc-int((max_abc-B)%2 != 0)
    answer += (max_abc-C)//2
    C = max_abc-int((max_abc-C)%2 != 0)

    if A == B == C:
        print(answer)
        return 

    if [A,B,C].count(max_abc) == 2:
        answer += 2
    else:
        answer += 1

    print(answer)

    
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  
    B = int(next(tokens))  
    C = int(next(tokens))  
    solve(A, B, C)

if __name__ == '__main__':
    main()

Solution (Python):
a = list(map(int,input().split()))
a.sort()
b = list(map(lambda x:x%2,a))
ans = 0

if sum(b) in (1,2):
    ans += 1
    for i in range(3):
        if sum(b) == 1:
            a[i] -= b[i]
        else:
            a[i] += b[i]

ans += (a[2]-a[0])//2+ (a[2]-a[1])//2
print(ans)

Solution (Python):
A = list(map(int,input().split()))

cnt = 0
while not(A[0]==A[1]==A[2]):
  A.sort()
  if A[1]!=A[2]:
    A[0]+=1
    A[1]+=1
  else:
    A[0]+=2
  cnt+=1
print(cnt)

Solution (Python):
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    a, b, c = list(map(int, readline().split()))
    dif = max([a, b, c]) * 3 - (a + b + c)
    print(dif // 2 if dif % 2 == 0 else (dif + 3) // 2)


if __name__ == '__main__':
    solve()

Solution (Python):
A,B,C = map(int, input().split())

max_num = max(A,B,C)

flg = 0
if (max_num*3%2 == (A+B+C)%2):
    target = max_num
else:
    target = max_num+1
    flg += 1

ans = (3*target-(A+B+C)) // 2
print(ans)

Solution (Python):
L = list(map(int, input().split()))
L.sort()


ans = 0
ans += L[2] - L[1]
L[0]+=ans
while L[2] > L[0]:
	L[0]+=2
	ans+=1

if L[2] == L[0]:
	print(ans)
else:
	print(ans+1)

Solution (Python):

A, B, C = map(int, input().split())

combi = [A, B, C]
set_abc = set(combi)

len_set_abc = len(set_abc)
max_set = max(set_abc)
min_set = min(set_abc)
if len_set_abc == 1:
    print(0)
elif len_set_abc == 2:
    max_freq = combi.count(max_set)
    diff = max_set - min_set
    if max_freq == 2 and diff % 2:
        print((diff + 1) // 2 + 1)
    elif max_freq == 2:
        print(diff // 2)
    else:
        print(diff)
else:
    other = [c for c in combi if c != max_set]
    max_other = max(other)
    min_other = min(other)
    
    n_operation = max_set - max_other
    max_other += n_operation
    min_other += n_operation

    diff = max_set - min_other

    if diff % 2:
        n_add = (max_set - min_other) // 2 + 2
    else:
        n_add = (max_set - min_other) // 2
    n_operation += n_add

    print(n_operation)

Solution (Python):

A, B, C = map(int, input().split())

combi = [A, B, C]
set_abc = set(combi)

len_set_abc = len(set_abc)
max_set = max(set_abc)
min_set = min(set_abc)
if len_set_abc == 1:
    print(0)
elif len_set_abc == 2:
    max_freq = combi.count(max_set)
    diff = max_set - min_set
    if max_freq == 2 and diff % 2:
        print((diff + 1) // 2 + 1)
    elif max_freq == 2:
        print(diff // 2)
    else:
        print(diff)
else:
    other = [c for c in combi if c != max_set]
    max_other = max(other)
    min_other = min(other)
    
    n_operation = max_set - max_other
    max_other += n_operation
    min_other += n_operation

    diff = max_set - min_other
    if diff % 2 and diff == 1:
        n_add = (max_set - min_other) // 2 + 2
    elif diff % 2:
        n_add = (max_set - min_other) // 2 + 2
    else:
        n_add = (max_set - min_other) // 2
    n_operation += n_add

    print(n_operation)

Solution (Python):
import sys
input = sys.stdin.readline
li = [int(i) for i in input().split()]
li.sort()
dk = li[2] - li[1]
dl = li[2] - li[0]
sum = dk
dl -= dk
while dl > 0 :
    if dl == 1 :
        sum+=2
        dl = 0
    else :
        dl -=2
        sum+=1
print(sum)

Solution (Python):
import sys

*a, = map(int, sys.stdin.readline().split())

def main():
    a.sort()
    res = a[2] * 2 - a[0] - a[1]
    return (res + 3) // 2 if res & 1 else res // 2
    
if __name__ == '__main__':
    ans = main()
    print(ans)

Solution (Python):
abc = sorted(list(map(int, input().split())))

first = abc[2] - abc[0]
second = abc[2] - abc[1]

cnt = 0

if first % 2 == 0 and second % 2 == 0:
    cnt += first//2 + second//2

elif (first % 2 == 1 and second % 2 == 0) or (first % 2 == 0 and second % 2 == 1):
    cnt += first//2 + second//2 + 2

else:
    cnt += first//2 + second//2 + 1

print(cnt)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    arr = LI()
    arr = sorted(arr)
    mod2_arr = [0, 0, 0]
    for i, a in enumerate(arr):
        mod2_arr[i] = a % 2

    if sum(mod2_arr) == 0 or sum(mod2_arr) == 3:
        ans = 0

    elif sum(mod2_arr) == 1:
        for i, a in enumerate(arr):
            if arr[i] % 2 == 0:
                arr[i] += 1
        arr = sorted(arr)
        ans = 1
    else:
        for i, a in enumerate(arr):
            if arr[i] % 2 == 1:
                arr[i] += 1
        arr = sorted(arr)
        ans = 1
    ans += (arr[2] - arr[0]) // 2 + (arr[2] - arr[1]) // 2
    print(ans)
main()

Solution (Python):
a,b,c=map(int,input().split())
cnt=0
m=max(a,b,c)
while a < m-1:
  cnt+=1
  a+=2
while b < m-1:
  cnt+=1
  b+=2
while c < m-1:
  cnt+=1
  c+=2
s=m*3
if s-a-b-c==0:
  print(cnt)
elif s-a-b-c==1:
  print(cnt+2)
else:
  print(cnt+1)

Solution (Python):
A,B,C = map(int,input().split())
D = max(A,B,C)
S = A+B+C
if (D*3 - S) % 2 == 0:
    ans = (D*3-S)//2
else:
    ans = ((D+1)*3-S)//2
print(ans)

Solution (Python):
A,B,C=sorted(map(int,input().split()))
Z=C-B
ZZ = (C-(A+Z))/2
ANS=0
if ZZ == (C-(A+Z))//2:
  ANS = Z + (C-(A+Z))//2
else:
  import math
  ANS = Z + math.ceil(ZZ) + 1
print(ANS)

Solution (Python):
a = list(map(int,input().split()))

a.sort()

count = 0


n = a[2]-a[1]
m = a[2]-a[0]


if (n % 2 == 1) and (m % 2 == 1) :
  count += 1


elif ((a[2]-a[1])%2 == 1) or ((a[2]-a[0])%2 == 1) :
  count += 2




count += (n//2)
count += (m//2)

print(count)

Solution (Python):
a = list(map(int,input().split()))

a.sort()

count = 0

if ((a[2]-a[1])%2 == 1) and ((a[2]-a[0])%2 == 1) :
  count += 1
elif ((a[2]-a[1])%2 == 1) or ((a[2]-a[0])%2 == 1) :
  count += 2

count += ((a[2]-a[1])//2)
count += ((a[2]-a[0])//2)

print(count)

Solution (Python):
abc = list(map(int,input().split()))
abc.sort()
A,B,C = abc[0],abc[1],abc[2]

if A%2 + B%2 == 1:
    C += 1
print((C*3-sum(abc))//2)

Solution (Python):
l=list(map(int,input().split()))
l.sort()

sa=l[2]-l[1]
sb=l[1]-l[0]

if sb % 2 == 0:
    print(sa+sb//2)
else:
    print(sa+sb//2+2)

Solution (Python):
li=list(map(int,input().split()))
li.sort()
if (li[1]-li[0])%2==1:
    print(int(li[2]-li[1]+1+(li[1]-li[0]+1)/2))
else:
    print(int(li[2]-li[1]+(li[1]-li[0])/2))

Solution (Python):
import sys
from math import ceil
a, b, c = [int(i) for i in sys.stdin.readline().split()]
INF = 10 ** 18
best = INF
for i in range(min(a, b, c), max(a, b, c) + 2):
    score = 0
    for j in [a, b, c]:
        if j < i:
            score += ceil((i - j) / 2)
            score += (i - j) % 2
        else:
            score += j - i
    best = min(best, score)
print(best)

Solution (Python):
A, B, C = map(int, input().split())

n = max(A, B, C)
t = n * 3 - sum([A, B, C])

if t % 2 == 0:
    ans = t // 2
else:
    ans = (t + 3) // 2

print(ans)

Solution (Python):
L=sorted(list(map(int,input().split())))
d1=L[1]-L[0]
d2=L[2]-L[1]
print(d1//2+d2 if d1%2==0 else d1//2+d2+2)

Solution (Python):
a = sorted(list(map(int, input().split())))
a = [a[2] - a[0], a[2] -  a[1], a[2] - a[2]]
if (a[0] - a[1])%2==0:
    print((a[0] - a[1])//2 + a[1])
else:
    print((a[0] - a[1])//2 + a[1] + 2)

Solution (Python):
nums = list(map(int, input().split()))

sumNum = sum(nums)
maxNum = max(nums)
count = 0

while True:
    if sumNum % 3 == 0 and sumNum/3 >= maxNum:
        break
    sumNum += 2
    count += 1

print(count)

Solution (Python):
A,B,C = list(map(int, input().split()))

a = A % 2
b = B % 2
c = C % 2

ans = 0
if (a == 0 and b == 0 and c == 1):
    A += 1
    B += 1
    ans += 1
elif (a == 0 and b == 1 and c == 0):
    A += 1
    C += 1
    ans += 1
elif (a == 1 and b == 0 and c == 0):
    B += 1
    C += 1
    ans += 1
elif (a == 1 and b == 0 and c == 1):
    A += 1
    C += 1
    ans += 1
elif (a == 1 and b == 1 and c == 0):
    A += 1
    B += 1
    ans += 1
elif (a == 0 and b == 1 and c == 1):
    B += 1
    C += 1
    ans += 1

arr = sorted([A,B,C])
l = arr[2]
m = arr[1]
n = arr[0]
ans += (l - m) // 2
ans += (l - n) // 2
print(ans)

Solution (Python):
s = list(map(int, input().split()))
s.sort()
d1 = s[2] - s[0]
d2 = s[2] - s[1]
ans = d1 // 2 + d2 // 2
y = d1 % 2 + d2 % 2
if y == 1:
  ans += 2
if y == 2:
  ans += 1
print(ans)

Solution (Python):
n = list(map(int,input().split()))
n.sort(reverse=True)
a = n[0]-n[1]
b = n[0]-n[2]
if a == 0 and b == 0:
    print(0)
if a != 0 and b == 0:
    if a%2 == 0:
        print(int(a/2))
    elif a == 1:
        print(2)
    elif a%2 != 0:
        print(int(2+(a-1)/2))
if a == 0 and b != 0:
    if b%2 == 0:
        print(int(b/2))
    elif b == 1:
        print(2)
    elif b%2 != 0:
        print(int(2+(b-1)/2))
if a != 0 and b != 0:
    if a == 1 and b == 1:
        print(1)
    elif a%2 == 0 and b%2 == 0:
        print(int(a/2+b/2))
    elif a%2 != 0 and b%2 == 0:
        print(int(2+(a-1)/2+b/2))
    elif a%2 == 0 and b%2 != 0:
        print(int(2+a/2+(b-1)/2))
    elif a%2 != 0 and b%2 != 0:
        print(int(1+(a-1)/2+(b-1)/2))

Solution (Python):
a, b, c = map(int, input().split())

max_n = max(a, b, c)

num = max_n * 3 - a - b - c

if num % 2 == 0:
    num = int(num / 2)
else:
    num = int((num + 1)/2 + 1)

print(num)

Solution (Python):
import sys
input = sys.stdin.readline
import numpy as np
A = np.array([int(x) for x in input().split()])
A = np.sort(A)
E = A[np.nonzero(A % 2 == 0)]
O = A[np.nonzero(A % 2 == 1)]
e, o = len(E), len(O)
if e == 0 or o == 0:
    a, b = A[-1] - A[0], A[-1] - A[1]
    print(a // 2 + b // 2)
elif e > o:
    A_2 = np.sort(np.concatenate([(E + 1), O]))
    a, b = A_2[-1] - A_2[0], A_2[-1] - A_2[1]
    print(1 + a // 2 + b // 2)
elif o > e:
    A_2 = np.sort(np.concatenate([(O + 1), E]))
    a, b = A_2[-1] - A_2[0], A_2[-1] - A_2[1]
    print(1 + a // 2 + b // 2)

Solution (Python):

import sys
input = sys.stdin.readline

a = list(map(int,input().split()))
cnt = 0
a.sort()
while len(set(a))>1:
    if a[0]!=a[2] and a[1]!=a[2]:
        a[0]+=1
        a[1]+=1
    elif a[2] - a[1] < 1 and a[1]==a[2]:
        a[0]+=2
    else:
        a[1]+=1
        a[2]+=1
    cnt+=1
    a.sort()
print(cnt)

Solution (Python):
L=list(map(int,input().split()))
L.sort()
if (L[1]+L[0])%2==0:
    print((L[2]-L[0]+L[2]-L[1])//2)
else:
    print((L[2]-L[0]+L[2]-L[1]+3)//2)

Solution (Python):

def main()->None:
    
    
    l = list(map(int, input().split()))
    l.sort()
    
    l[0] = l[2] - l[0]
    l[1] = l[2] - l[1]
    l[2] = 0
    
    
    count = 0
    while True:
        if l[1] - 2 < 0:
            if l[1] == 0:
                break
            else:
                l[1] -= 1
                l[0] -= 1
                count += 1
                break
        l[1] -= 2
        count += 1

    
    while True:
        if l[0] <= 0:
            if l[0] == 0:
                flag = True
                break
            if l[0] < 0:
                count += 1
                break
        l[0] -= 2
        count += 1
    print(count)


if __name__ == "__main__":
    main()

Solution (Python):
nums=list(map(int, input().split()))
nums.sort()
odds=[nums[i]%2 for i in range(3)]
counter=0
if sum(odds)==2:
  for i in range(3):
    if odds[i]==1:
      nums[i]+=1
      
  counter+=1
  
if sum(odds)==1:
  for i in range(3):
    if odds[i]==0:
      nums[i]+=1
      
  counter+=1
  
counter+=(2*nums[2]-nums[0]-nums[1])//2
print(counter)

Solution (Python):
a,b,c=map(int,input().split())
li=[a,b,c]
li.sort()
x=li[1]-li[0]
y=li[2]-li[1]

if not x%2:
  print((2*y+x)//2)
else:
  print(((2*y+x)//2)+2)

Solution (Python):
a = list(map(int, input().split()))
cnt = 0 
a.sort()
if a[2] > a[1]:
        cnt += a[2] - a[1]
        a[1] += cnt 
        a[0] += cnt 
if a[1] > a[0]:
        if (a[1] % 2 == 0) ^ (a[0] % 2 == 0): 
                cnt += (a[1] + 1 - a[0]) // 2 + 1 
        else:
                cnt += (a[1] - a[0]) // 2
print(cnt)

Solution (Python):
a,b,c=map(int,input().split())
m = max(a,b,c)
r = m*3-(a+b+c)
if r % 2 ==0:print(r//2)
else:print(r//2+2)

Solution (Python):
a = list( map(int, input().split()) )

cnt = 0
while not a[0] == a[1] == a[2]:
    arr = a.sort()
    cnt += 1
    if a[0] == a[1] :
        a[0] += 1
        a[1] += 1
        continue
    if a[1] == a[2] :
        a[0] += 2
        continue
    else:
        min_id = a.index(min(a))
        a[min_id] += 2
        continue
print(cnt)

Solution (Python):
a, b, c = sorted(map(int, input().split()))
cnt = c - b
a += cnt
b += cnt
print(cnt + (b - a) // 2 + (b - a) % 2 * 2)

Solution (Python):
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    a, b, c = list(map(int, readline().split()))
    sn = sum([a, b, c])
    mn = max(a, b, c)
    for i in range(mn * 3, 10 ** 10, 3):
        if (i - sn) % 2 == 0:
            print((i - sn) // 2)
            exit()


if __name__ == '__main__':
    solve()

Solution (Python):
ABC = list(map(int, input().split()))

sm = sum(ABC)
mx = max(ABC)

if (mx * 3) % 2 == sm % 2:
    ans = (mx * 3 - sm) // 2
else:
    ans = ((mx + 1) * 3 - sm) // 2

print(ans)

Solution (Python):
a, b, c = sorted(map(int,input().split()))

if (b-a)%2==0:
    print((b-a)//2+c-b)
else:
    print((b-a+1)//2+c-b+1)

Solution (Python):
ls = sorted(list(map(int,input().split())))
x = ls[2]*2 - ls[0] - ls[1]
if x%2 == 1:
    x += 3
print(x//2)

Solution (Python):

import sys
L = list(map(int, sys.stdin.readline().split()))
L.sort()

cnt =0
while True:
    if L[2]-L[0] >=2:
        L[0]+=2
        cnt+=1
        L.sort()
    elif L[2]-L[1] >=2:
        L[1]+=2
        cnt+=1
        L.sort()
    elif L[0] != L[1] or L[0] !=L[2]:
        L[0]+=1
        L[1]+=1
        cnt+=1
        L.sort()
    
    if L[0]==L[1] and L[1]==L[2]:
        break


print(cnt)

Solution (Python):
a = list(map(int,input().split()))
a.sort()
suma = 0
if (a[1] - a[0])%2 == 0:
    suma += (a[1] - a[0])//2
else:
    suma += (a[1] - a[0])//2 + 1
    a[1] -= 1

suma += a[2] - a[1]
print(suma)

Solution (Python):
import sys
L=list(map(int,sys.stdin.readline().split()))
cnt=0
while True:
  if L[0]==L[1]==L[2]:
    break
  L.sort()
  if L[2]-L[0]>=2:
    L[0]+=2
  elif L[2]-L[1]>=2:
    L[1]+=2
  elif L[0] !=L[1] or L[1] !=L[2]:
    L[0]+=1
    L[1]+=1
  cnt+=1
  
print(cnt)

Solution (Python):
a, b, c = map(int, input().split())
x = max(a, b, c)
total = a + b + c
if x % 2 != total % 2:
    x += 1
print((3 * x - total) // 2)

Solution (Python):
abc = list(map(int, input().split()))
abc.sort()
ans = 0
cnt = 0
rest = 0
for i in range(3):
    if abc[i] % 2 == 0:
        cnt += 1
if cnt == 0 or cnt == 3:
    print((abc[2] - abc[1]) // 2 + (abc[2] - abc[0]) // 2)
    exit()
elif cnt == 1:
    rest = 1
for i in range(3):
    if abc[i] % 2 == rest:
        abc[i] += 1
abc.sort()
print((abc[2] - abc[1]) // 2 + (abc[2] - abc[0]) // 2 + 1)

Solution (Python):
x = list(map(int, input().split()))
m = max(x)
d = [v - m for v in x]
count = 0
while sum(d) != 0:
    ix = [i for i in range(len(x)) if x[i] != m]
    if len(ix) == 2:
        x[ix[0]] += 1
        x[ix[1]] += 1
    if len(ix) == 1:
        x[ix[0]] += 2
    m = max(x)
    d = [v - m for v in x]
    count += 1
print(count)

Solution (Python):
l = list(map(int, input().split()))

ans = 0

maxl = max(l)

for i in range(3):
	if l[i]==maxl:
		pass
	else:
		while maxl-2 >= l[i]:
			l[i] = l[i] + 2
			ans = ans + 1

minl = min(l)

k = []
for i in range(3):
	k.append(l[i]-minl)

if sum(k)==0:
	pass
elif sum(k)==2:
	ans = ans + 2
elif sum(k)==1:
	ans = ans + 1

print(ans)

Solution (Python):
an = list(map(int, input().split()))
an.sort()
x = an[2] * 2 - an[0] - an[1]
if x % 2 == 1:
  x += 3
print(x // 2)

Solution (Python):
l=list(map(int,input().split()))
l.sort()
a=l[0]
b=l[1]
c=l[2]
if (b-a)%2==0:
    print(c-b+(b-a)//2)
else:
    if c%2==0:
        if b%2==0:
            print((c+1-a)//2+(c-b)//2+1)
        else:
            print((c+1-b)//2+(c-a)//2+1)
    else:
        if b%2==0:
            print((c-a)//2+(c+1-b)//2+1)
        else:
            print((c-b)//2+(c+1-a)//2+1)

Solution (Python):
a,b,c=sorted(map(int,input().split()))
counter=0
if a%2==b%2:
	counter+=(b-a)//2
	counter+=c-b
elif a%2==c%2:
	counter+=(c-a)//2
	counter+=(c-b)//2+1+1
elif b%2==c%2:
	counter+=(c-b)//2
	counter+=(c-a)//2+1+1
print(counter)

Solution (Python):
n = list(map(int, input().split()))

n.sort()

c = 0

c += n[2] - n[1]

if c > 0:
    n[0] += c
    n[1] += c

if (n[1] - n[0]) % 2 == 0:
    c += (n[1] - n[0]) // 2
else:
    c += (n[1] - n[0]) // 2 + 2
print(c)

Solution (Python):
a, b, c = sorted(map(int, input().split()))
cnt = c - b
if (b - a) % 2:
    print((b - a) // 2 + cnt + 2)
else:
    print((b - a) // 2 + cnt)

Solution (Python):
a=list(map(int,input().split()))
o=0
e=0
ans=0
for i in range(3):
    if a[i]%2==0:
        e+=1
    else:
        o+=1
if e==2:
    ans+=1
    for i in range(3):
        if a[i]%2==0:
            a[i]+=1
elif e==1:
    ans+=1
    for i in range(3):
        if a[i]%2==1:
            a[i]+=1
a.sort()
print(ans+a[2]-a[1]+(a[1]-a[0])//2)

Solution (Python):
num_list = list(map(int, input().split()))
A, B, C = sorted(num_list)
ans = 0

if A % 2 == B % 2 == C % 2:
    ans += (C - B) // 2
    ans += (C - A) // 2
    print(ans)
elif A % 2 == B % 2 != C % 2:
    A += 1
    B += 1
    ans += 1
    ans += (C - B) // 2
    ans += (C - A) // 2
    print(ans) 
elif A % 2 == C % 2 != B % 2:
    ans += (C - A) // 2
    ans += (C - B) // 2 + 1
    ans += 1
    print(ans)
elif B % 2 == C % 2 != A % 2:
    ans += (C - B) // 2
    ans += (C - A) // 2 + 1
    ans += 1
    print(ans)

Solution (Python):
import math
A = list(map(int,input().split()))
A.sort(reverse=True)
cnt1 = (A[0] - A[1]) / 2
cnt2= (A[0] - A[2]) / 2


d1 ,i1 = math.modf(cnt1)
d2 ,i2 = math.modf(cnt2)

if d1 + d2 == 1:
    both_increase = 1
elif d1 + d2 == 0.5:
    both_increase = 2
else:
    both_increase = 0
print(int(i1 + i2 + both_increase))

Solution (Python):
n = list(map(int,input().split()))
d = max(n)
s = sum(n)
if (3*d-s)%2 == 0:
    print(int((3*d-s)/2))
else:print(int((3*(d+1)-s)/2))

Solution (Python):
A,B,C = map(int, input().split())
m = max(A,B,C)
k = m-A+m-B+m-C
if k % 2 == 0:
  print(k // 2)
else:
  print((k+3)//2)

Solution (Python):
A, B, C = map(int, input().split())

M = max(A, B, C)

if M % 2 == (A + B + C) % 2:
    X = M
else:
    X = M + 1

ans = (3 * X - (A + B + C)) // 2
print(ans)

Solution (Python):


import numpy as np
import scipy





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


def plus1(X, Y):
    return X+1, Y+1

def plus2(Z):
    return Z+2

c = 0
S = sorted(S)

while True:
    if S[1] == S[2]:
        break
    S[0], S[1] = plus1(S[0], S[1])
    c += 1

if (S[1] - S[0])%2 != 0:
    S[1], S[2] = plus1(S[1], S[2])
    c += 1

while True:
    if S[0] == S[1]:
        break
    S[0] = plus2(S[0])
    c += 1

print(c)

Solution (Python):
s = list(map(int, input().split()))
s.sort()
if((3 * s[2]) % 2 == sum(s) % 2):
  print(((2 * s[2]) - s[0] - s[1]) // 2) 
else:
  print(((2 * s[2]+1) - s[0] - s[1]) // 2 + 1)

Solution (Python):
L = sorted(list(map(int, input().split())))
d = L[2]-L[1]
count = d
L[0] += d
L[1] += d
s = L[1]-L[0]
count += s//2
if s%2 == 1:
  count += 2
print(count)

Solution (Python):
nums = [int(i) for i in input().split()]
Max = max(nums)
a = Max - nums[0]
b = Max - nums[1]
c = Max - nums[2]
 
d = a + b + c
  
if d % 2 != 0 :
  a += 1
  b += 1
  c += 1
    
print( (a+b+c)//2 )

Solution (Python):
A,B,C = sorted(list(map(int,input().split())))
D = C-B + C-A
if D%2 ==0:
    ans = D//2
else:
    ans = 1+(D+1)//2
print(ans)

Solution (Python):
N = list(map(int, input().split()))
N = sorted(N, reverse=True)

one = N[0] - N[1]
two = N[0] - N[2]

ans = 0

if one % 2 == 0 and two % 2 == 0:
    ans += one /2 + two /2
elif one % 2 == 1 and two % 2 == 1:
    ans += one //2 + two //2 + 1
else:
    ans += one //2 + two //2 + 2

print(int(ans))

Solution (Python):
import math
lst = list(map(int, input().split()))
lst.sort()
cnt = 0
cnt += lst[2] - lst[1]
x = math.ceil((lst[2] - lst[0] - cnt)/2)
if (lst[2] - lst[0] - cnt)%2 == 1:
  print(cnt + x + 1)
else:
  print(cnt + x)

Solution (Python):
A,B,C=map(int, input().split())
diff=max(A,B,C)*3-A-B-C

if diff%2==0:
    print(diff//2)
else:
    print((diff+3)//2)

Solution (Python):
a,b,c = sorted(map(int,input().split()))
if a % 2 == b % 2:
  d1 = (b - a) // 2
  d2 = c - b
  print(d1 + d2)
else:
  d1 = (b - a) // 2
  d1 += 1
  d2 = c - b
  d2 += 1
  print(d1 + d2)

Solution (Python):
L = sorted(list(map(int, input().split())))
if L[2]*3%2==sum(L)%2:
    print(int(sum([L[2]-i for i in L])/2))
else:
    print(int((sum([L[2]+1-i for i in L])-2)/2+1))

Solution (Python):
A,B,C=sorted(map(int,input().split()))
ab=B-A
bc=C-B
if ab%2!=0:
  bc=bc+1
  ab=ab+1
print(ab//2+bc)

Solution (Python):
A,B,C=map(int,input().split())
L=sorted([A,B,C])
ab=L[1]-L[0]
bc=L[2]-L[1]
if ab%2!=0:
  bc=bc+1
  ab=ab+1
print(ab//2+bc)

Solution (Python):
a,b,c = sorted(map(int,input().split()))



if a%2 == b%2:
  t1 = (b-a) // 2
  t2 = c - b
  print(t1 + t2)

else:
  t1 = (b-a) // 2
  t1 += 1
  t2 = c + 1 - b
  print(t1+t2)

Solution (Python):
a,b,c=map(int,input().split())
m=max(a,b,c)
r=m-a+m-b+m-c
if r%2==0:
  ans=r//2
else:
  ans=(r+3)//2
print(ans)

Solution (Python):
import numpy as np
a,b,c=map(int,input().split())
l=[a,b,c]
arr=np.array(l)
m=max(arr)
t=m-arr

s=sum(t)
if s%2==0:
  ans=s//2
else:
  ans=(s+3)//2
print(ans)

Solution (Python):
abc=list(map(int,input().split()))
count=0
while not abc[0]==abc[1]==abc[2]:
    count+=1
    abc.sort()
    if abc[0]==abc[1]:
        abc[0]+=1
        abc[1]+=1
    else:
        abc[0]+=2
    
print(count)

Solution (Python):
import sys
A, B, C = map(int, input().split())

lis = sorted([A, B, C])

ans = 0
while lis[1] != lis[2] and lis[1]+1 != lis[2]:
  lis[1] += 2
  ans += 1

while lis[0] != lis[2] and lis[0]+1 != lis[2]:
  lis[0] += 2
  ans += 1

if lis[2] == lis[1] and lis[1] == lis[0]:
  print(ans)
elif lis[2] != lis[0] and lis[2] != lis[1]:
  print(ans+1)
else:
  print(ans+2)

Solution (Python):
v = sorted(list(map(int,input().split())))
cnt = 0
while v[0]!=v[2]:
    if v[2]-v[0]>=2:
        cnt += (v[2]-v[0])//2
        v[0]+=((v[2]-v[0])//2)*2
    elif v[2]-v[0]==1:
        v[0]+=1
        v[1]+=1
        cnt+=1
    v.sort()
print(cnt)

Solution (Python):
def examC():
    ABC = LI(); ABC.sort()
    ans = (ABC[2]*2-ABC[1]-ABC[0]+1)//2 + (ABC[2]*2-ABC[1]-ABC[0])%2
    print(ans)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()

Solution (Python):
import numpy as np
V=np.array(input().split(),dtype=int)

maxv=V.max()
minv=V.min()
midv=int(np.median(V))

print((maxv-midv)+(midv-minv)//2+((midv-minv)%2)*2)

Solution (Python):
num = list(map(int, input().split()))
ans = 0

while num[0] != num[1] or num[1] != num[2] or num[0] != num[2]:
    num.sort()
    if num[0] + 1 == num[2] and num[1] + 1 == num[2]:
        num[0] += 1
        num[1] += 1

    else:
        num[0] += 2

    ans += 1
print(ans)

Solution (Python):
a,b,c = map(int,input().split())

m = max(a,b,c)
n = (m - a) + (m - b) + (m - c)

if n % 2 == 0:
    print(n // 2)
else:
    print(n // 2 + 2)

Solution (Python):
abc = [int(x) for x in input().split()]
abc = sorted(abc)

num = 0
while True:

    if (abc[0] == abc[1]) & (abc[1] == abc[2]):
        break

    if (abc[0] == abc[1]):
        abc[0] +=1
        abc[1] +=1
        abc = sorted(abc)
        num += 1
        continue

    if (abc[0] < abc[1]):
        abc[0] += 2
        abc =sorted(abc)
        num += 1
        continue

print(num)

Solution (Python):
a, b, c = sorted(map(int, input().split()))
if (b-a)%2:
  ans = c-b + (b-a+3)//2
else:
  ans = c-b + (b-a)//2
print(ans)

Solution (Python):
ABC = list(map(int, input().split()))

odd_num = []
for i in range(len(ABC)):
    if ABC[i] % 2 != 0:
        odd_num.append(i)
        
if len(odd_num) == 0 or len(odd_num) == 3:
    count = 0
elif len(odd_num) == 1:
    for i in range(len(ABC)):
        if i not in odd_num:
            ABC[i] += 1
    count = 1
elif len(odd_num) == 2:
    for i in range(len(ABC)):
        if i in odd_num:
            ABC[i] += 1
    count = 1
    
max_ABC = max(ABC)
for i in range(len(ABC)):
    if ABC[i] != max_ABC:
        count += (max_ABC - ABC[i]) // 2

print(count)

Solution (Python):
A, B, C = map(int, input().split())





A, B, C = sorted([A, B, C])

cnt = 0
cnt += (C - A) // 2 
cnt += (C - B) // 2


if (B - A) % 2 == 0:
    if (C - A) % 2 != 0:
        cnt += 1
else:
    cnt += 2

print(cnt)

Solution (Python):
l = sorted(map(int,input().split()))
a=2*l[2]-l[1]-l[0]
print((a+3)//2 if a%2 else a//2)

Solution (Python):
a=list(map(int,input().split()))
a=sorted(a)
diff=(a[2]-a[0])+(a[2]-a[1])
if diff%2==0:
    print(diff//2)
else:
    print(diff//2+2)

Solution (Python):
a,b,c = map(int, input().split())
maxi = max(a, b, c)
diff = (maxi - a) + (maxi -b) + (maxi -c)
if diff % 2 == 0:
    print(int(diff / 2))
else:
    print(int((diff+3) /2))

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    A=list(map(int,input().split()))
    A.sort()
    a,b,c=A
    ans=0

    
    ans+=c-b
    a+=c-b
    b=c

    
    if((c-a)&1):
        ans+=(c-a+1)//2+1
    else:
        ans+=(c-a)//2
    print(ans)

resolve()