module Memoizable
    def memoize(name)
        original = "__original_#{name}__"
        ([Class, Module].include?(self.class) ? self : self.class).class_eval {
            alias_method(original, name)
            private(original)
            cache = {}
            define_method(name){|*args|
                cache[args] ||= send(original, *args)
            }
        }
    end
end

include Memoizable

def f(n)
    return [n, 1].max if n <= 2
    f(n-3) + f(n-2) + f(n-1)
end

memoize :f

loop do
    n = gets.to_i
    break if n == 0
    p (f(n) / 3650.0).ceil
end