import Data.Char main = getLine >>= print . solve . map (read :: String -> Int) . words . foldr ff "" where ff x acc | isDigit x = x : acc | x == '-' = ' ' : x : acc | otherwise = ' ' : acc solve :: [Int] -> Int solve (x : xs) | head y < 0 = ((read $ drop 2 sy ++ sx) :: Int) + sum ys + ((read $ take 2 sy) :: Int) | otherwise = ((read $ tail sy ++ sx) :: Int) + sum ys + ((read [head sy]) :: Int) where (ys, y) = splitAt (length xs - 1) xs sy = show $ head y sx = show x