while gets
  arr = $_.chomp.split("").map{ |c| c.to_i }
  
  n = arr.length - 1
  
  n.times do |i|
    (n - i).times do |j|
      arr[j] = (arr[j] + arr[j + 1]) % 10
    end
  end
  
  puts arr[0]
end