n = int(input())
b = n // 100
s = n // 10 % 10
g = n // 1 % 10
if b > s and b > g and s > g:
    print(b - g)
if b > s and b > g and s < g:
    print(b - s)
if s > b and s > g and b > g:
    print(s - g)
if s > b and s > g and b < g:
    print(s - b)
if g > s and g > b and s > b:
    print(g - b)
if g > s and g > b and s < b:
    print(g - s)

/**************************************************************
	Problem: 1667
	User: admin
	Language: Python
	Result: Accepted
	Time:92 ms
	Memory:34480 kb
****************************************************************/