l = [int(x) for x in list(str(input()))] print(max(l) - min(l))