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