lst = [int(i) for i in input().strip()] print(max(lst) - min(lst))