abc = list(input()) K = max(abc) A = min(abc) J = int(K) - int(A) print(J)