#include <iostream>

#define MAX_N 30
#define INF -1

int memo[MAX_N], ans, n;

void solve();

int dp(int a);

int answer(int in);

int main(){
    while(true){
        std::cin >> n;
        
        if(n == 0)
            break;
        
        for(int i = 0; i < MAX_N; ++i)
            memo[i] = INF;
        
        solve();
        
        std::cout << answer(ans) << std::endl;
    }
    return 0;
}

void solve(){
    ans = dp(n + 1);
    return;
}

int dp(int a){
    if(a < 1) return 0;
    if(a == 1) return 1;
    
    if(memo[a] == INF){
        memo[a] = dp(a - 1) + dp(a - 2) + dp(a - 3);
        return memo[a];
    }
    
    return memo[a];	
}

int answer(int in){
    int count = 1;
    while(true){
        if(count <= 365) break;
        count -= 365;
        ++count;
    }
}