import Data.List

main = do
  str <- getLine
  let list = map read (words str) ::[Int]
      list' = (reverse . sort) list
  print $ cal list'


cal :: [Int] -> Int
cal [] = 0
cal [x] = 0
cal (x:xs) = (x - head xs) + cal xs
