v = [int(c) for c in input()] print(max(v) - min(v))