s = list(input()) s.sort() print(int(s[-1])-int(s[0]))