n = int(input()) a = n // 100 b = (n - (a*100)) // 10 c = (n - (a*100) - (b*10)) max_num = max(a,b,c) min_num = min(a,b,c) print(max_num - min_num)