#include<iostream>

using namespace std;

int func(int x);

int main() {
	int x;
	while (true) {
		cin >> x;
		if (x == 0) { break; }
		cout << func(x) / 3650 + 1 << endl;
	}
	
	return 0;
}

int func(int x) {
	if (x == 1) {
		return 1;
	}
	else if (x == 2) {
		return 2;
	}
	else if (x == 3) {
		return 4;
	}
	else {
		return func(x - 1) + func(x - 2) + func(x - 3);
	}
}
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <queue>
#include <stdlib.h>
 
using namespace std;
 
int main(void){
	
	int n;
	cin >> n;

	for( int i = 0; i < n; i++ ) {
		int outs = 0, runner = 0, pts = 0;
		while( outs < 3 ) {
			string evt;
			cin >> evt;
			if( evt == "HIT" ) {
				if( runner < 3 ) {
					runner ++;
				} else {
					pts ++;
				}
			} else if( evt == "OUT" ) {
				outs ++;
			} else {
				pts += runner + 1;
				runner = 0;
			}
		}
		cout << pts << endl;
	}

	return 0;
}