#!/usr/bin/env ruby input = $stdin.readlines[0].strip.to_i scores = [3, 7] elf1 = 0 elf2 = 1 loop do se1 = scores[elf1] se2 = scores[elf2] sum = se1 + se2 scores += sum.to_s.chars.map(&:to_i) slen = scores.length elf1 = (elf1 + 1 + se1) % slen elf2 = (elf2 + 1 + se2) % slen break if slen > (input + 10) end puts scores[input...(input+10)].join