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