L=list(map(int,__import__("sys").stdin.read().split(",")))
print(min(sum(abs(l-i) for l in L) for i in range(min(L), max(L)+1)))