while (line = gets)
  ns = line.chomp.split("").map{|s| s.to_i}

  while ns.length > 1
    ns0 = []
    for i in (1...ns.length)
      ns0.push (ns[i - 1] + ns[i]) % 10
    end
    ns = ns0
  end

  puts ns[0]
end