i=map(int,input()) print(max(i)-min(i))