def Bottommost( string )
	src  = string.split(//).map{|i| i.to_i}
	while src.size > 1
		dest = Array.new
		0.upto( src.size - 2 ){ |n|
			dest << (src[ n ] + src [n + 1]) % 10
		}
		src = dest.dup
	end
	src[ 0 ]	
end

answers = Array.new
while line = $stdin.gets
	answers << Bottommost( line.chomp )
end
answers.each{ |a| puts a }
