#!/usr/bin/env python3 l=list(map(int,list(open("input.txt"))[0].split(',')));l.sort();print(sum(abs(x-l[((len(l)+1)//2)-1])for x in l))