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-----
2 5 4

-----Sample Output-----
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.

Difficulty: MEDIUM_HARD

Starter code:

Solutions:
a = list(map(int, input().split()))
a.sort(reverse=True)
ans = 0
ans += a[0] - a[1]
a[1] += ans
a[2] += ans
ans += (a[0] - a[2]) // 2
ans += (a[0] - a[2]) % 2 * 2
print(ans)


(A, B, C) = list(map(int, input().split()))
sum_l = A + B + C
max_l = max(A, B, C)
dif = 3 * max_l - sum_l
if dif % 2 == 0:
	print(dif // 2)
else:
	print(dif // 2 + 2)


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


lista = list(map(int, input().split()))
lista.sort()
count = 0
A = lista[0]
B = lista[1]
C = lista[2]
while A != B or B != C or C != A:
	if C - A >= 2:
		lista[0] += 2
	else:
		lista[0] += 1
		lista[1] += 1
	lista.sort()
	A = lista[0]
	B = lista[1]
	C = lista[2]
	count += 1
print(count)


L = sorted(list(map(int, input().split())))
cnt = 0
while L[0] < L[2] - 2:
	cnt += 1
	L[0] += 2
while L[1] < L[2] - 2:
	cnt += 1
	L[1] += 2
if L[0] % 2 == L[1] % 2 and L[1] % 2 == L[2] % 2:
	if L[0] < L[2]:
		cnt += 1
	if L[1] < L[2]:
		cnt += 1
elif L[0] == L[1]:
	cnt += 1
elif L[1] == L[2]:
	cnt += 2
else:
	cnt += 3
print(cnt)


lst = list(map(int, input().split()))
lst.sort()
count = 0
while len(set(lst)) != 1:
	for i in range(len(lst) - 2):
		if lst[i] <= lst[i + 1] - 2:
			lst[i] += 2
		elif lst[i] <= lst[i + 2] and lst[i + 1] <= lst[i - 1]:
			lst[i] += 1
			lst[i + 1] += 1
	count += 1
	lst.sort()
print(count)


ABC = list(map(int, input().split()))
odds = [x for x in ABC if x % 2]
evens = [x for x in ABC if x % 2 == 0]
ans = 0
if len(odds) == 2:
	odds[0] += 1
	odds[1] += 1
	ans += 1
elif len(evens) == 2:
	evens[0] += 1
	evens[1] += 1
	ans += 1
ABC = sorted(odds + evens)
ans += (ABC[2] - ABC[0]) // 2 + (ABC[2] - ABC[1]) // 2
print(ans)


X = [int(x) for x in input().split()]
list.sort(X, reverse=True)
(A, B, C) = (X[0], X[1], X[2])
count = 0
while A != B or B != C or C != A:
	if (B - C) % 2 == 1 and A == B:
		A = A + 1
		B = B + 1
		count = count + 1
	elif B != C and (B - C) % 2 == 0:
		while B != C:
			C = C + 2
			count = count + 1
	else:
		B = B + 1
		C = C + 1
		count = count + 1
print(count)


(A, B, C) = map(int, input().split())
c = 0
if A == B == C:
	print(0)
else:
	while True:
		if max(A, B, C) >= 2 + min(A, B, C):
			(A, B, C) = (max(A, B, C), A + B + C - max(A, B, C) - min(A, B, C), min(A, B, C) + 2)
		else:
			(A, B, C) = (max(A, B, C), A + B + C - max(A, B, C) - min(A, B, C) + 1, min(A, B, C) + 1)
		c += 1
		if A == B == C:
			break
	print(c)


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


def main():
	l = list(map(int, input().split()))
	(even, odd) = ([], [])
	for i in l:
		if i % 2 != 0:
			odd.append(i)
		else:
			even.append(i)
	even.sort()
	odd.sort()
	if len(even) == 3:
		return (even[2] * 2 - even[0] - even[1]) // 2
	if len(even) == 2:
		a = max(odd[0], even[1] + 1)
		b = min(odd[0], even[1] + 1)
		return (a * 2 - (even[0] + 1) - b) // 2 + 1
	if len(odd) == 2:
		a = max(even[0], odd[1] + 1)
		b = min(even[0], odd[1] + 1)
		return (a * 2 - (odd[0] + 1) - b) // 2 + 1
	if len(even) == 0:
		return (odd[2] * 2 - odd[0] - odd[1]) // 2
ans = main()
print(ans)


ABC = list(map(int, input().split()))
ans = 0
ABC.sort()
if ABC[0] == ABC[1] == ABC[2]:
	ans = 0
elif ABC[0] != ABC[1] and ABC[1] != ABC[2]:
	sa = ABC[2] - ABC[1]
	ans += sa
	ABC[0] += sa
	ans += -(-(ABC[2] - ABC[0]) // 2)
	if (ABC[2] - ABC[0]) % 2 == 1:
		ans += 1
elif ABC[0] == ABC[1]:
	ans += ABC[2] - ABC[0]
elif ABC[1] == ABC[2]:
	ans += -(-(ABC[2] - ABC[0]) // 2)
	if (ABC[2] - ABC[0]) % 2 == 1:
		ans += 1
print(ans)


L = sorted(list(map(int, input().split())), reverse=True)
ans = 0
if (L[1] - L[2]) % 2 != 0:
	L[0] += 1
	L[1] += 1
	ans += 1
ans += L[0] - L[1] + (L[1] - L[2]) // 2
print(ans)


a = list(map(int, input().split()))
ma = max(a)
d = ma * 3 - sum(a)
print(d // 2 if d % 2 == 0 else d // 2 + 2)


(a, b, c) = map(int, input().split())
a1 = max(a, b, c)
c1 = min(a, b, c)
b1 = a + b + c - a1 - c1
if b1 % 2 == c1 % 2:
	print(int((2 * a1 - c1 - b1) / 2))
else:
	print(int((2 * (a1 + 1) - c1 - b1) / 2) + 1)


nums = list(map(int, input().split()))
nums.sort(reverse=True)
ans = nums[0] - nums[1]
nums[1] = nums[0]
nums[2] += ans
ans += (nums[0] - nums[2]) // 2
if (nums[0] - nums[2]) % 2 == 1:
	print(ans + 2)
elif (nums[0] - nums[2]) % 2 == 2:
	print(ans + 1)
else:
	print(ans)


A = list(map(int, input().split()))
A.sort()
ans = 0
count = [0, 0]
for a in A:
	if a & 1:
		count[1] += 1
	else:
		count[0] += 1
if count[0] == 0 or count[1] == 0:
	m = A[2]
	ans += 3 * m - sum(A)
	ans //= 2
elif A[1] - A[0] & 1:
	m = A[2] + 1
	ans += 3 * m - sum(A)
	ans //= 2
else:
	m = A[2]
	ans += 3 * m - sum(A)
	ans //= 2
print(ans)


(a, b, c) = map(int, input().split())
maxn = max(max(a, b), c)
minn = min(min(a, b), c)
midn = a + b + c - minn - maxn
ans = maxn - midn
anss = 1001001
if (maxn - ans - minn) % 2 == 0:
	ans += (maxn - ans - minn) / 2
else:
	ans += (maxn - ans - minn) // 2 + 2
if (maxn - midn) % 2 == (maxn - minn) % 2:
	anss = (maxn - midn + 1) // 2 + (maxn - minn + 1) // 2
ans = min(ans, anss)
print(int(ans))


line = list(map(int, input().split(' ')))
line.sort()
min_n = line[0]
mid_n = line[1]
max_n = line[2]
res = 0
res = res + max_n - mid_n
res = res + int((mid_n - min_n) / 2)
if mid_n - min_n & 1:
	res = res + 2
print(res)


l = input().split(' ')
l2 = [int(i) for i in l]
A = min(l2)
l2.remove(A)
C = max(l2)
l2.remove(C)
B = l2[0]
count = 0
if A == B == C:
	pass
else:
	n = C - B
	if n % 2 == 0:
		count = count + n // 2
		B = C
	else:
		count = count + n // 2 + 1
		B = C
		A = A + 1
	m = C - A
	if m % 2 == 0:
		count = count + m // 2
	else:
		count = count + m // 2 + 2
print(count)


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


a = list(map(int, input().split()))
count = 0
while a[0] != a[1] or a[1] != a[2]:
	a.sort()
	if a[1] != a[2]:
		a[0] += 1
		a[1] += 1
	else:
		a[0] += 2
	count += 1
print(count)


(a, b, c) = map(int, input().split())
lis = [a, b, c]
lis.sort(reverse=True)
maxi = lis[0]
mid = lis[1]
mini = lis[2]
cnt = 0
while maxi > mid:
	cnt += 1
	mini += 1
	mid += 1
if (maxi - mini) % 2 == 0:
	cnt += (maxi - mini) // 2
else:
	cnt += (maxi - mini + 1) // 2 + 1
print(cnt)


A = list(map(int, input().split()))
even = []
odd = []
for i in range(3):
	if A[i] % 2 == 0:
		even.append(A[i])
	else:
		odd.append(A[i])
ans = 0
if len(even) == 3:
	even.sort(reverse=True)
	ans += (even[0] - even[1]) // 2
	ans += (even[0] - even[2]) // 2
elif len(even) == 2:
	even.sort(reverse=True)
	if odd[0] < even[0]:
		ans += -(-(even[0] - odd[0]) // 2)
		odd[0] += 2 * ans
	ans += (even[0] - even[1]) // 2
	ans += odd[0] - even[0]
elif len(even) == 1:
	odd.sort(reverse=True)
	if even[0] < odd[0]:
		ans += -(-(odd[0] - even[0]) // 2)
		even[0] += 2 * ans
	ans += (odd[0] - odd[1]) // 2
	ans += even[0] - odd[0]
else:
	odd.sort(reverse=True)
	ans += (odd[1] - odd[2]) // 2
	ans += odd[0] - odd[1]
print(ans)


import sys
input = sys.stdin.readline
ins = lambda : input().rstrip()
ini = lambda : int(input().rstrip())
inm = lambda : map(int, input().split())
inl = lambda : list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))
a = sorted(inl())
n = a[2] - a[1] + a[2] - a[0]
print((n + 2 - 1) // 2 + 1 if n % 2 else n // 2)


(A, B, C) = map(int, input().split())
l = sorted([A, B, C])
d = l[2] - l[0]
e = l[1] - l[0]
if d * e == 0:
	ans = d
elif d == e:
	ans = d // 2 + 2 * (d % 2)
elif d % 2 == e % 2 == 0:
	ans = d // 2 + (d - e) // 2
elif e % 2 == 0:
	ans = d // 2 + (d - e) // 2 + 1
elif d % 2 == 0:
	ans = d // 2 + (d - e) // 2 + 2
else:
	ans = d // 2 + (d - e) // 2 + 2
print(ans)


num = list(map(int, input().split()))
numSort = sorted(num)
count = numSort[2] - numSort[1]
count += (numSort[2] - (numSort[0] + count)) / 2
count = int(count) if count.is_integer() else int(count + 1.5)
print(count)


(A, B, C) = map(int, input().split())
a = b = c = False
odd = 0
if A % 2:
	odd += 1
	a = True
if B % 2:
	odd += 1
	b = True
if C % 2:
	odd += 1
	c = True
result = 0
if odd == 1:
	if a:
		B = B + 1
		C = C + 1
		result += 1
	elif b:
		A = A + 1
		C = C + 1
		result += 1
	elif c:
		A = A + 1
		B = B + 1
		result += 1
if odd == 2:
	if a & b:
		A = A + 1
		B = B + 1
		result += 1
	elif b & c:
		B = B + 1
		C = C + 1
		result += 1
	elif a & c:
		A = A + 1
		C = C + 1
		result += 1
result += int((3 * max(A, B, C) - A - B - C) / 2)
print(result)


l = sorted(list(map(int, input().split())))
(d, e, f) = (l[2] - l[0], l[1] - l[0], l[2] - l[1])
if d * e == 0:
	ans = d
elif d == e:
	ans = d // 2 + 2 * (d % 2)
elif d % 2 == e % 2 == 0:
	ans = d // 2 + f // 2
elif e % 2 == 0:
	ans = d // 2 + f // 2 + 1
else:
	ans = d // 2 + f // 2 + 2
print(ans)


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


mod = 1000000007
eps = 10 ** (-9)

def main():
	import sys
	input = sys.stdin.readline
	ans = 0
	(a, b, c) = list(map(int, input().split()))
	if a % 2 != c % 2 and b % 2 != c % 2:
		ans += 1
		a += 1
		b += 1
	elif b % 2 != a % 2 and c % 2 != a % 2:
		ans += 1
		b += 1
		c += 1
	elif c % 2 != b % 2 and a % 2 != b % 2:
		ans += 1
		c += 1
		a += 1
	(a, b, c) = sorted([a, b, c])
	ans += (c - a) // 2
	ans += (c - b) // 2
	print(ans)

def __starting_point():
	main()
__starting_point()


(a, b, c) = list(map(int, input().split()))
m = max(a, b, c)
sub = 3 * m - a - b - c
if sub % 2 != 0:
	sub += 3
print(sub // 2)


a = list(map(int, input().split()))
m = max(a)
t = m * 3 - sum(a)
if t % 2 == 1:
	t += 3
print(t // 2)


A = sorted(map(int, input().split()))
count_odds = 0
for a in A:
	if a & 1:
		count_odds += 1
if count_odds == 0 or count_odds == 3:
	print((A[2] * 2 - A[0] - A[1]) // 2)
elif count_odds == 2:
	for i in range(3):
		if A[i] & 1:
			A[i] += 1
	print((A[2] * 2 - A[0] - A[1]) // 2 + 1)
else:
	for i in range(3):
		if A[i] % 2 == 0:
			A[i] += 1
	print((A[2] * 2 - A[0] - A[1]) // 2 + 1)


import copy
import sys
import math
tmp = input().split()
(a, b, c) = list([int(a) for a in tmp])
hoge = max(a, b, c) * 3 - a - b - c
if hoge % 2 == 0:
	print(hoge // 2)
else:
	print(hoge // 2 + 2)


import sys
ls = list(map(int, input().split()))
ls.sort()
cnt = 0
for i in [0, 1]:
	c = (ls[2] - ls[i]) // 2
	cnt += c
	ls[i] += 2 * c
if (ls[0] == ls[1]) & (ls[2] - 1 == ls[1]):
	cnt += 1
elif (ls[0] == ls[2] - 1) | (ls[1] == ls[2] - 1):
	cnt += 2
print(cnt)


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


(A, B, C) = sorted(map(int, input().split()))
C -= A
B -= A
ans = 0
ans += C % 2
C -= C % 2
ans += B % 2
B -= B % 2
ans += 2 * (C // 2)
ans -= B // 2
print(ans)


(a, b, c) = sorted(map(int, input().split()))
(d, e) = (c - a, c - b)
print(d // 2 + e // 2 + (3 - d % 2 - e % 2) % 3)


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


def solve(a, b, c):
	ans = 0
	if a & 1 != b & 1 and a & 1 != c & 1:
		ans += 1
		b += 1
		c += 1
	elif b & 1 != a & 1 and b & 1 != c & 1:
		ans += 1
		a += 1
		c += 1
	elif c & 1 != a & 1 and c & 1 != b & 1:
		ans += 1
		a += 1
		b += 1
	return ans + (c - b) // 2 + (c - a) // 2
print(solve(*sorted(map(int, input().split()))))


A = list(map(int, input().split()))
A.sort(reverse=True)
X = A[0] - A[1] + (A[0] - A[2])
print(X // 2 + 2 * (X % 2))


import numpy as np
abc = np.array([int(a) for a in input().split()])
abc = abc - np.array([np.min(abc)] * 3)
abc = np.sort(abc)
ans = 0
if abc[1] == 0:
	ans = abc[2]
elif abc[1] % 2 == 0:
	ans += abc[1] // 2
	ans += abc[2] - abc[1]
else:
	ans += 1
	abc[0] += 1
	abc[2] += 1
	ans += (abc[1] - abc[0]) // 2
	ans += abc[2] - abc[1]
print(ans)


L = list(map(int, input().split()))
tmp = 3 * max(L) - sum(L)
if tmp % 2 == 0:
	print(tmp // 2)
else:
	print((tmp + 3) // 2)


l = list(map(int, input().split()))
ref = max(l) * 3 - sum(l)
if ref % 2 == 0:
	ans = ref // 2
else:
	ans = ref // 2 + 2
print(ans)


(g, b, c) = list(map(int, input().split()))
a = [g, b, c]
a.sort()
t = a[2] - a[0]
h = a[2] - a[1]
ans = t // 2 + h // 2
for i in range(3):
	a[i] = a[i] % 2
if a[0] == 0:
	if a[1] == 0:
		if a[2] == 0:
			print(ans)
		else:
			print(ans + 1)
	else:
		print(ans + 2)
elif a[1] == 0:
	print(ans + 2)
elif a[2] % 2 == 0:
	print(ans + 2)
else:
	print(ans)


X = list(map(int, input().split()))
X.sort(reverse=True)
(A, B, C) = (X[0], X[1], X[2])
(P, Q) = (X[0] - X[1], X[0] - X[2])
dam = P + Q
if dam % 2 == 0:
	if P % 2 == 0 and Q % 2 == 0:
		out = dam // 2
	else:
		out = (dam - 2) // 2 + 1
else:
	out = (dam - 1) // 2 + 2
print(out)


import numpy as np
(a, b, c) = list(map(int, input().split()))
L = np.array([a, b, c])
d = (L % 2).sum()

def calc(a, b, c):
	e = a + b + c
	max1 = max(a, b, c)
	min1 = min(a, b, c)
	mid = e - max1 - min1
	return (max1 * 2 - mid - min1) // 2
if d == 3 or d == 0:
	print(calc(a, b, c))
elif d == 1:
	if a % 2 == 1:
		b += 1
		c += 1
		print(calc(a, b, c) + 1)
	elif b % 2 == 1:
		a += 1
		c += 1
		print(calc(a, b, c) + 1)
	elif c % 2 == 1:
		a += 1
		b += 1
		print(calc(a, b, c) + 1)
elif d == 2:
	if a % 2 == 0:
		b += 1
		c += 1
		print(calc(a, b, c) + 1)
	elif b % 2 == 0:
		a += 1
		c += 1
		print(calc(a, b, c) + 1)
	elif c % 2 == 0:
		a += 1
		b += 1
		print(calc(a, b, c) + 1)


abc = sorted(list(map(int, input().split())))
ans = 0
while len(set(abc)) != 1:
	ans += 1
	if abc[-1] - abc[0] >= 2:
		abc[0] += 2
	else:
		abc[0] += 1
		abc[1] += 1
	abc.sort()
print(ans)


a = list(map(int, input().split()))
cnt = 0
for i in range(3):
	if a[i] % 2 == 1:
		cnt += 1
if cnt == 0 or cnt == 3:
	print((3 * max(a) - sum(a)) // 2)
elif cnt == 1 and max(a) % 2 == 1 or (cnt == 2 and max(a) % 2 == 0):
	print((max(a) - a[0]) // 2 + (max(a) - a[1]) // 2 + (max(a) - a[2]) // 2 + 1)
else:
	print((max(a) + 1 - a[0]) // 2 + (max(a) + 1 - a[1]) // 2 + (max(a) + 1 - a[2]) // 2 + 1)


lst = list(map(int, input().split()))
mval = max(lst)
sval = sum(lst)
cn = mval + (sval - mval) % 2
n = (cn * 3 - sval) // 2
print(n)


def solve():
	A = list(map(int, input().split()))
	A.sort(reverse=True)
	diff_0_1 = A[0] - A[1]
	A[1] += diff_0_1
	A[2] += diff_0_1
	cnt = diff_0_1
	diff_0_2 = A[0] - A[2]
	if diff_0_2 % 2 == 0:
		cnt += diff_0_2 // 2
	else:
		cnt += diff_0_2 // 2 + 1 + 1
	print(cnt)

def __starting_point():
	solve()
__starting_point()


(A, B, C) = sorted(map(int, input().split()))
(a, b) = divmod(2 * C - A - B, 2)
print(a + b * 2)


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


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


import sys

def solve(A: int, B: int, C: int):
	a = sorted([A, B, C])
	o = sum([x & 1 for x in a])
	c = 0 < o and o < 3
	if o == 2:
		for i in range(3):
			a[i] += a[i] & 1
	elif o == 1:
		for i in range(3):
			a[i] += 1 - (a[i] & 1)
	print((2 * a[2] - a[1] - a[0]) // 2 + c)

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)

def __starting_point():
	main()
__starting_point()


lst = sorted(list(map(int, input().split())))
mval = lst[-1]
sval = sum(lst)
cn = mval + (sval - mval) % 2
n = (cn * 3 - sval) // 2
print(n)


import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect

class Scanner:

	def int():
		return int(sys.stdin.readline().rstrip())

	def string():
		return sys.stdin.readline().rstrip()

	def map_int():
		return [int(x) for x in Scanner.string().split()]

	def string_list(n):
		return [input() for i in range(n)]

	def int_list_list(n):
		return [Scanner.map_int() for i in range(n)]

	def int_cols_list(n):
		return [int(input()) for i in range(n)]

class Math:

	def gcd(a, b):
		if b == 0:
			return a
		return Math.gcd(b, a % b)

	def lcm(a, b):
		return a * b // Math.gcd(a, b)

	def roundUp(a, b):
		return -(-a // b)

	def toUpperMultiple(a, x):
		return Math.roundUp(a, x) * x

	def toLowerMultiple(a, x):
		return a // x * x

	def nearPow2(n):
		if n <= 0:
			return 0
		if n & n - 1 == 0:
			return n
		ret = 1
		while n > 0:
			ret <<= 1
			n >>= 1
		return ret

	def isPrime(n):
		if n < 2:
			return False
		if n == 2:
			return True
		if n % 2 == 0:
			return False
		d = int(n ** 0.5) + 1
		for i in range(3, d + 1, 2):
			if n % i == 0:
				return False
		return True
MOD = int(1000000000.0) + 7

def main():
	(A, B, C) = Scanner.map_int()
	ans = 0
	if not A % 2 == B % 2 == C % 2:
		ans += 1
		if A % 2 == B % 2:
			A += 1
			B += 1
		elif B % 2 == C % 2:
			B += 1
			C += 1
		else:
			A += 1
			C += 1
	D = max(A, B, C)
	ans += (D - A) // 2
	ans += (D - B) // 2
	ans += (D - C) // 2
	print(ans)

def __starting_point():
	main()
__starting_point()


ma = lambda : map(int, input().split())
lma = lambda : list(map(int, input().split()))
ni = lambda : int(input())
yn = lambda fl: print('Yes') if fl else print('No')
import collections
import math
import itertools
import heapq as hq
abc = lma()
abc.sort()
b = abc[2] - abc[0]
c = abc[2] - abc[1]
if b % 2 == 0 and c % 2 == 0:
	ans = b // 2 + c // 2
elif b % 2 == 1 and c % 2 == 1:
	ans = (b - 1) // 2 + (c - 1) // 2 + 1
else:
	ans = b // 2 + c // 2 + 2
print(ans)


int_list = list(map(int, input().split()))
int_list_min = sorted(int_list)
max_diff = int_list_min[2] - int_list_min[0]
min_diff = int_list_min[2] - int_list_min[1]
ans = 0
if (max_diff + min_diff) % 2 == 1:
	ans += 1
	min_diff += 1
ans += (max_diff - min_diff) // 2 + min_diff
print(ans)


(A, B, C) = map(int, input().split())
maximam = max(A, B, C)
count = (maximam - A) // 2 + (maximam - B) // 2 + (maximam - C) // 2
A += (maximam - A) // 2 * 2
B += (maximam - B) // 2 * 2
C += (maximam - C) // 2 * 2
if A == B and B == C:
	print(count)
elif A == B and A == maximam or (C == B and C == maximam) or (A == C and C == maximam):
	print(count + 2)
else:
	print(count + 1)


import math
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions import gcd
(a, b, c) = map(int, input().split())
l = [a, b, c]
l.sort()
cnt = l[2] - l[1]
c = math.ceil((l[2] - (l[0] + cnt)) / 2)
if l[0] + 2 * c + cnt == l[2]:
	print(cnt + c)
else:
	print(cnt + c + 1)


(a, b, c) = map(int, input().split())
ans = 0
while 1:
	if a == b and b == c:
		print(ans)
		break
	ans += 1
	if a == min(a, b, c):
		a += 1
		if a == min(a, b, c):
			a += 1
		elif b == min(a, b, c):
			b += 1
		else:
			c += 1
	elif b == min(a, b, c):
		b += 1
		if a == min(a, b, c):
			a += 1
		elif b == min(a, b, c):
			b += 1
		else:
			c += 1
	else:
		c += 1
		if a == min(a, b, c):
			a += 1
		elif b == min(a, b, c):
			b += 1
		else:
			c += 1


(A, B, C) = map(int, input().split())
lst = [A, B, C]
lst.sort()
ans = 0
if (lst[1] - lst[0]) % 2 == 0:
	ans += (lst[1] - lst[0]) // 2 + lst[2] - lst[1]
elif (lst[2] - lst[0]) % 2 != 0:
	ans += (lst[2] - lst[1]) // 2 + (lst[2] + 1 - lst[0]) // 2 + 1
elif (lst[2] - lst[1]) % 2 != 0:
	ans += (lst[2] - lst[0]) // 2 + (lst[2] + 1 - lst[1]) // 2 + 1
print(ans)


import sys
import math
import itertools
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
input = sys.stdin.readline

def RD():
	return input().rstrip()

def F():
	return float(input().rstrip())

def I():
	return int(input().rstrip())

def MI():
	return map(int, input().split())

def MF():
	return map(float, input().split())

def LI():
	return list(map(int, input().split()))

def TI():
	return tuple(map(int, input().split()))

def LF():
	return list(map(float, input().split()))

def Init(H, W, num):
	return [[num for i in range(W)] for j in range(H)]

def main():
	(A, B, C) = MI()
	a = min(A, B, C)
	c = max(A, B, C)
	b = A + B + C - a - c
	ans = 0
	if (b - a) % 2 == 1:
		a += 1
		c += 1
		ans += 1
	ans += (b - a) // 2
	ans += c - b
	print(ans)

def __starting_point():
	main()
__starting_point()


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

def main():
	m = max(A, B, C)
	s = sum([m - A, m - B, m - C])
	ans = (s + 1) // 2
	if s % 2 == 1:
		ans += 1
	print(ans)

def __starting_point():
	main()
__starting_point()


(A, B, C) = sorted(map(int, input().split()))
ans = (C - A) // 2 + (C - B) // 2
A += 2 * ((C - A) // 2)
B += 2 * ((C - B) // 2)
if A == B:
	if A < C:
		ans += 1
else:
	ans += 2
print(ans)


(a, b, c) = sorted(list(map(int, input().split())))
cnt = 0
while b < c:
	a += 1
	b += 1
	cnt += 1
while a < c:
	a += 2
	cnt += 1
print(cnt if a == c else cnt + 1)


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


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


def main():
	(A, B, C) = list(map(int, input().split()))
	X = [A, B, C]
	X.sort()
	if X[0] == X[2]:
		print(0)
	elif X[0] == X[1]:
		print(X[2] - X[1])
	elif X[1] == X[2]:
		if (X[1] - X[0]) % 2 == 1:
			print((X[1] - X[0]) // 2 + 2)
		else:
			print((X[1] - X[0]) // 2)
	elif (X[1] - X[0]) % 2 == 0:
		print(X[2] - X[1] + (X[1] - X[0]) // 2)
	else:
		print(X[2] - X[1] + (X[1] - X[0]) // 2 + 2)

def __starting_point():
	main()
__starting_point()


A = list(map(int, input().split()))
A.sort()
a_max = A[2]
a_middle = A[1]
a_min = A[0]
ans = 0
if sum(A) % 2 != 3 * a_max % 2:
	ans += 1
	a_max += 1
	a_middle += 1
ans += a_max - a_middle
ans += (a_max - (a_min + (a_max - a_middle))) // 2
print(ans)


lst = list(map(int, input().split()))
(s, m) = (sum(lst), max(lst))
if not (3 * m - s) % 2:
	print((3 * m - s) // 2)
else:
	print((3 * (m + 1) - s) // 2)


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


import numpy as np
(A, B, C) = list(map(int, input().split()))
vals = np.array([A, B, C])
vals = np.sort(vals)
sumval = vals.sum()
cn = vals[-1] + np.sum(vals[:2]) % 2
n = (3 * cn - sumval) // 2
print(n)


(a, b, c) = map(int, input().split())
ans = 100000
for i in range(-10, 60):
	cnt = 0
	for x in [a, b, c]:
		while x < i:
			x += 2
			cnt += 1
		cnt += x - i
	ans = min(ans, cnt)
print(ans)


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


N = list(map(int, input().split()))
N.sort()
cnt = 0
cnt += N[2] - N[1]
(x, y) = divmod(N[1] - N[0], 2)
cnt += x + y * 2
print(cnt)


l = sorted(list(map(int, input().split())))
if (l[2] - l[1]) % 2 == 0 and (l[2] - l[0]) % 2 == 0:
	print((l[2] - l[1]) // 2 + (l[2] - l[0]) // 2)
elif (l[2] - l[1]) % 2 == 0 and (l[2] - l[0]) % 2 != 0:
	print((l[2] - l[1]) // 2 + (l[2] - l[0]) // 2 + 2)
elif (l[2] - l[1]) % 2 != 0 and (l[2] - l[0]) % 2 == 0:
	print((l[2] - l[1]) // 2 + (l[2] - l[0]) // 2 + 2)
else:
	print((l[2] - l[1]) // 2 + (l[2] - l[0]) // 2 + 1)


import sys
readline = sys.stdin.readline
read = sys.stdin.read
A = [*list(map(int, readline().split()))]
A.sort()
(a, b, c) = A
v = c
ans = 0
while a < v - 1:
	a += 2
	ans += 1
while b < v - 1:
	b += 2
	ans += 1
if a == b == c - 1:
	a += 1
	b += 1
	ans += 1
if a == c - 1:
	ans += 2
if b == c - 1:
	ans += 2
print(ans)


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


import itertools
import sys
input = sys.stdin.readline
L = list(map(int, input().split()))
(A, B, C) = sorted(L)
ans = 0
if (B - A) % 2 == 0:
	ans += (B - A) // 2
	ans += C - B
else:
	ans += (B - A) // 2 + 1
	ans += 1
	ans += C - B
print(ans)


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


(a, b, c) = map(int, input().split())
a_ = a % 2
b_ = b % 2
c_ = c % 2
if [a_, b_, c_].count(1) == 0:
	max_ = max([a, b, c])
	print(abs((a - max_ + (b - max_) + (c - max_)) // 2))
elif [a_, b_, c_].count(1) == 1:
	list_ = []
	for i in range(len([a_, b_, c_])):
		if [a_, b_, c_][i] == 0:
			list_.append([a, b, c][i] + 1)
		else:
			list_.append([a, b, c][i])
	max_ = max(list_)
	print(abs(list_[0] - max_ + (list_[1] - max_) + (list_[2] - max_)) // 2 + 1)
elif [a_, b_, c_].count(1) == 2:
	list_ = []
	for i in range(len([a_, b_, c_])):
		if [a_, b_, c_][i] == 1:
			list_.append([a, b, c][i] + 1)
		else:
			list_.append([a, b, c][i])
	max_ = max(list_)
	print(abs(list_[0] - max_ + (list_[1] - max_) + (list_[2] - max_)) // 2 + 1)
else:
	max_ = max([a, b, c])
	print(abs((a - max_ + (b - max_) + (c - max_)) // 2))


from math import ceil
Q = list(map(int, input().split()))
Q.sort()
(A, B, C) = Q
print(C - B + ceil((B - A) / 2) + ((B - A) % 2 == 1))


(a, b, c) = list(map(int, input().split()))
ma = max(a, b, c)
ans = (ma - a) // 2 + (ma - b) // 2 + (ma - c) // 2
a = 2 * ((ma - a) // 2) + a
b = 2 * ((ma - b) // 2) + b
c = 2 * ((ma - c) // 2) + c
ma = max(a, b, c)
cnt0 = 0
sa = [ma - a, ma - b, ma - c]
for i in sa:
	if i == 0:
		cnt0 += 1
if cnt0 == 3:
	print(ans)
elif cnt0 == 2:
	print(ans + 2)
elif cnt0 == 1:
	print(ans + 1)


a = sorted(list(map(int, input().split())))
x = 0
i = (a[1] - a[0]) // 2
x += i
a[1] -= i * 2
a[2] -= i * 2
i = a[2] - a[1]
a[2] -= i
x += i
print(x + sum(a) - a[0] * 3)


(a, b, c) = list(map(int, input().split()))
r = 3 * max(a, b, c) - sum([a, b, c])
if r % 2:
	print(r // 2 + 2)
else:
	print(r // 2)