S = list(input()) S = [int(i) for i in S] print(max(S) - min(S))