ls = list(map(int,list(input()))) print(max(ls)-min(ls))