#encoding:utf-8
def make_bottommost ary
 if ary.length == 1
  return ary
 else
  i = 0
  ary2 = []
  while i+1 < ary.length
   ary2.push (ary[i]+ary[i+1])%10
   i += 1
  end
  make_bottommost ary2
 end
end

num_ary = []

while true
 num = gets.chomp.chars
 num.length.times do |i|
  num[i] = num[i].to_i
 end

 if num == []
  break
 end

 num_ary.push num
end

num_ary.length.times do |i|
 puts make_bottommost num_ary[i]
end