while line = gets
  arr = []
  
  line.chomp!.each_char do |c|
    arr << c.to_i
  end
  
  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