import sys input=lambda:sys.stdin.readline().rstrip() A=list(map(int,list(input()))) print(max(A)-min(A))