import Data.Char (digitToInt)

main = interact $ unlines.map (show.calcBottommost.map digitToInt).lines

unitDigit :: Int -> Int -> Int
unitDigit a b = (a+b) `mod` 10

calcDigits :: [Int] -> [Int]
calcDigits (x:y:[]) = unitDigit x y : []
calcDigits (x:y:ys) = unitDigit x y : calcDigits (y:ys)

calcBottommost :: [Int] -> Int
calcBottommost [x] = x
calcBottommost xs = calcBottommost $ calcDigits xs