main :: IO()
main = do
  list <- reverse . map str2Int. sort . words <$> getLine
  print $ func list

 
str2Int :: String -> Int
str2Int = read

func [_] = 0
func list = sum $ zipWith (-) list (tail list)