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