import           Data.Char (ord)
import           Data.List (unfoldr)

solve :: [Int] -> Int
solve [] = 0
solve xs = head $ last $ unfoldr f xs
  where f [] = Nothing
        f xs = Just (xs, g [] xs)
        g ans [_]        = reverse ans
        g ans (x1:x2:xs) = g (((x1 + x2) `mod` 10):ans) (x2:xs)

main :: IO ()
main = getContents >>= mapM_ (print . solve . map (\c -> ord c - 0x30)) . lines