abc = input() M = max(map(int, abc)) m = min(map(int, abc)) print(M - m)