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