Go: package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
	"strconv"
)

func CountPatterns(i int, patternNums []int) int {
	if patternNums[i] != 0 {
		return patternNums[i]
	}
	if i == 0 {
		return 1
	}
	patternNums[i] += CountPatterns(i-1, patternNums)
	if i > 1 {
		patternNums[i] += CountPatterns(i-2, patternNums)
	}
	if i > 2 {
		patternNums[i] += CountPatterns(i-3, patternNums)
	}
	return patternNums[i]
}

func Solve(N int) int {
	patternNums := MakeFilledInts(N+1, 0)
	return (CountPatterns(N, patternNums) + 3649) / 3650
}

func main() {
	for N := scan.Int(); N != 0; N = scan.Int() {
		ans := Solve(N)
		fmt.Println(ans)
	}
}

// --------------------------------------------------------------------------------
// Input

var scan = NewScanner()

type Scanner struct{ *bufio.Scanner }

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(nil, 100000000)
	return &Scanner{sc}
}

func (s *Scanner) String() string {
	s.Scan()
	return s.Text()
}

func (s *Scanner) Strings(l int) []string {
	if l == 0 {
		return []string{}
	}
	sl := make([]string, l, l)
	for i := range sl {
		sl[i] = s.String()
	}
	return sl
}

func (s *Scanner) Int() int {
	n, _ := strconv.Atoi(s.String())
	return n
}

func (s *Scanner) Ints(l int) []int {
	if l == 0 {
		return []int{}
	}
	sl := make([]int, l, l)
	for i := range sl {
		sl[i] = s.Int()
	}
	return sl
}

func (s *Scanner) Int64() int64 {
	n, _ := strconv.ParseInt(s.String(), 10, 64)
	return n
}

func (s *Scanner) BigInt() *big.Int {
	return big.NewInt(s.Int64())
}

func (s *Scanner) BigInts(l int) []*big.Int {
	if l == 0 {
		return []*big.Int{}
	}
	sl := make([]*big.Int, l, l)
	for i := range sl {
		sl[i] = s.BigInt()
	}
	return sl
}

func (s *Scanner) Float64() float64 {
	f, _ := strconv.ParseFloat(s.String(), 64)
	return f
}

func (s *Scanner) Floats64(l int) []float64 {
	if l == 0 {
		return []float64{}
	}
	sl := make([]float64, l, l)
	for i := range sl {
		sl[i] = s.Float64()
	}
	return sl
}

// --------------------------------------------------------------------------------
// Output

const (
	Yes = "Yes"
	No  = "No"

	YES = "YES"
	NO  = "NO"
)

func PrintBool(v bool, trueStr, falseStr string) {
	if v {
		fmt.Println(trueStr)
	} else {
		fmt.Println(falseStr)
	}
}

// --------------------------------------------------------------------------------
// sort.BigIntSlice

type BigIntSlice []*big.Int

func (sl BigIntSlice) Len() int {
	return len(sl)
}

func (sl BigIntSlice) Less(i, j int) bool {
	return sl[i].Cmp(sl[j]) == -1
}

func (sl BigIntSlice) Swap(i, j int) {
	sl[i], sl[j] = sl[j], sl[i]
}

// --------------------------------------------------------------------------------
// Mint

const (
	Mod = 1000000007
)

type Mint int

func NewMint(value int) Mint {
	return Mint((value%Mod + Mod) % Mod)
}

func (x Mint) Add(y Mint) Mint {
	if v := x + y; v >= Mod {
		return v - Mod
	} else {
		return v
	}
}

func (x Mint) Sub(y Mint) Mint {
	if v := x + Mod - y; v >= Mod {
		return v - Mod
	} else {
		return v
	}
}

func (x Mint) Mul(y Mint) Mint {
	return (x * y) % Mod
}

func (x Mint) pow(n int) Mint {
	if n == 0 {
		return Mint(1)
	}
	a := x.pow(n >> 1)
	a = a.Mul(a)
	if n&1 != 0 {
		a = a.Mul(x)
	}
	return a
}

func (x Mint) Inverse() Mint {
	return x.pow(Mod - 2)
}

func (x Mint) Div(y Mint) Mint {
	return x * y.Inverse()
}

func (x Mint) Neg() Mint {
	return NewMint(int(-x))
}

// --------------------------------------------------------------------------------
// Factorial

type Factorial struct {
	fact        []Mint
	factInverse []Mint
}

func NewFactorial(n int) *Factorial {
	f := new(Factorial)
	f.init(n)
	return f
}

func (f *Factorial) init(n int) {
	fact := make([]Mint, n+1, n+1)
	fact[0] = NewMint(1)
	for i := 1; i <= n; i++ {
		fact[i] = fact[i-1].Mul(NewMint(i))
	}

	inv := make([]Mint, n+1, n+1)
	inv[n] = fact[n].Inverse()
	for i := n; i >= 1; i-- {
		inv[i-1] = inv[i].Mul(NewMint(i))
	}

	f.fact = fact
	f.factInverse = inv
}

func (f *Fa

C++: #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int dp[41];


int main(){
    memset(dp,0,sizeof(dp));
    dp[0] = 1;
    for(int j=0;j<30;j++){
	for(int i=1;i<=3;i++){
	    dp[i+j] += dp[j];
	}
    }
    while(true){
	int n;
	cin >> n;
	if(n == 0) break;
	int fact = dp[n]/10 + ((dp[n]%365==0) ? 0 : 1) ;
	cout << fact/365 + ((fact%365==0) ? 0 : 1) << endl;
    }
    return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;

int main(){
  int n;
  long long int ans[30];
  for(int i =0;i < 30; i++){
    if(i == 0)ans[i] = 1;
    else if(i == 1)ans[i] = ans[i-1] + 1;
    else if(i == 2)ans[i] = ans[i-1] + ans[i-2] + 1;
    else ans[i] = ans[i-1] + ans[i-2] + ans[i-3];
  }
  while(1){
    cin >> n;
    if(n == 0)break;
    if(ans[n-1]%3650 == 0) cout<<ans[n-1]/3650 << endl;
    else  cout << ans[n-1]/3650 + 1 <<endl;
  }
}

C++: #define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0168"

#include<bits/stdc++.h>
using namespace std;

#define call_from_test
#ifndef call_from_test
#include<bits/stdc++.h>
using namespace std;
#endif
//BEGIN CUT HERE
template<typename R>
struct Kitamasa{
  using VR = vector<R>;
  VR cs;
  vector<VR> rs;
  int m;

  Kitamasa(const VR &C)
    :cs(C),rs(1),m(C.size()){
    rs[0].assign(2*m+1,R::add_identity());
    rs[0][1]=R::mul_identity();
  }

  VR merge(const VR &xs,const VR &ys){
    VR zs(2*m+1,R::add_identity());
    for(int i=1;i<=m;i++)
      for(int j=1;j<=m;j++)
        zs[i+j]=zs[i+j]+(xs[i]*ys[j]);

    for(int i=2*m;i>m;zs[i--]=R::add_identity())
      for(int j=1;j<=m;j++)
        zs[i-j]=zs[i-j]+(cs[m-j]*zs[i]);
    return zs;
  }

  R calc(const VR &A,long long n){
    assert((int)A.size()==m);
    VR res(rs[0]);
    for(int i=0;n;i++,n>>=1){
      if(i>=(int)rs.size())
        rs.emplace_back(merge(rs[i-1],rs[i-1]));
      if(~n&1) continue;
      res=merge(res,rs[i]);
    }
    R ans=R::add_identity();
    for(int i=1;i<=m;i++) ans=ans+(res[i]*A[i-1]);
    return ans;
  }
};
//END CUT HERE
#ifndef call_from_test

#define call_from_test
#include "../mod/mint.cpp"
#undef call_from_test

//INSERT ABOVE HERE
signed TDPC_F(){
  using ll = long long;
  int n;
  ll k;
  scanf("%d %lld",&n,&k);

  using M = Mint<int>;
  vector<M> as(n,1),cs(n,1);
  Kitamasa<M> fib(cs);

  printf("%d\n",fib.calc(as,--k).v);
  return 0;
}
/*
  verified on 2019/12/10
  https://atcoder.jp/contests/tdpc/tasks/tdpc_fibonacci
*/

signed ABC009_D(){
  int k,m;
  scanf("%d %d",&k,&m);

  struct M{
    uint32_t v;
    M(){*this=add_identity();}
    M(uint32_t v):v(v){}
    M operator+(const M &a)const{return M(v^a.v);}
    M operator*(const M &a)const{return M(v&a.v);}
    static M add_identity(){return M(0);}
    static M mul_identity(){return M(~0u);}
  };

  vector<M> as(k),cs(k);
  for(int i=0;i<k;i++) scanf("%u",&as[i].v);
  for(int i=0;i<k;i++) scanf("%u",&cs[k-(i+1)].v);
  Kitamasa<M> v(cs);

  printf("%u\n",v.calc(as,--m).v);
  return 0;
}
/*
  verified on 2019/12/10
  https://atcoder.jp/contests/abc009/tasks/abc009_4
*/

signed main(){
  //TDPC_F();
  //ABC009_D();
  return 0;
}
#endif

#undef call_from_test

template<typename T>
struct Z{
  T v;
  Z(){*this=add_identity();}
  Z(T v):v(v){}
  Z operator+(const Z &a)const{return Z(v+a.v);}
  Z operator*(const Z &a)const{return Z(v*a.v);}
  static Z add_identity(){return Z(0);}
  static Z mul_identity(){return Z(1);}
};

signed main(){
  using ZL = Z<long long>;

  vector<ZL> as({0,0,1}),cs({1,1,1});
  Kitamasa<ZL> K(cs);

  int n;
  while(cin>>n,n)
    cout<<(K.calc(as,n+2).v+3650-1)/3650<<endl;

  return 0;
}