import Data.Char  -- digitToInt

bottommost xs = head $ iterate nextline xs !! (length xs - 1)

nextline (x : y : xs) = ((x + y) `mod` 10) : nextline (y : xs)
nextline _ = []

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