import Control.Applicative
import Data.Char
main = do
  v <- map (map (\x->ord(x) - ord('0'))) . lines  <$> getContents
  mapM_ (putStrLn . show . solve) v

solve::[Int] -> Int
solve v = head $ aux v
  where
    aux ::[Int] -> [Int]
    aux f = if length f == 1 then
              f
            else
              aux (zipWith (\x y->(x+y) `mod` 10) f (tail f))