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