import Data.Char  -- digitToInt

bottommost :: [Int] -> Int
bottommost [x] = x
bottommost xs  = bottommost (nextline xs)

nextline :: [Int] -> [Int]
nextline [x] = []
nextline (x : y : xs) = ((x + y) `mod` 10) : nextline (y : xs)

main = do
  s <- getContents
  putStr . unlines . map (show . bottommost . map digitToInt) . lines $ s