{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import qualified Data.ByteString.Char8 as BS
import           Data.List             (sort)
import           Data.Maybe            (fromJust)

main :: IO ()
main = do
  as <- map readInt . BS.words <$> BS.getLine
  print $ solve as

solve :: [Int] -> Int
solve as = sum . map (uncurry (-)) $ zip (tail as') as' where
  as' = sort as

readInt :: BS.ByteString -> Int
readInt = fst . fromJust . BS.readInt
