S=[int(a) for a in input()] print(max(S)-min(S))