L = [int(c) for c in input()] print(max(L)-min(L))