S = input() l = [] for s in S: l.append(int(s)) l.sort() print(l[-1] - l[0])