let onesdigit x y = (x + y) mod 10

let rec bottom lst r c = 
  if r = 0 then List.nth lst c
  else onesdigit (bottom lst (r - 1) c ) (bottom lst (r - 1) (c + 1))

let _ =
  try
    while true do
      let lst = List.map int_of_string (Str.split (Str.regexp "") (read_line ())) in
      print_endline @@ string_of_int @@ bottom lst 9 0
    done
  with
    End_of_file -> ()