a = list(map(int, list(input()))) print(max(a) - min(a))