#include<iostream>


typedef struct k {
	int N;
	int day;
};

int main() {
	k a[30];
	int c,N[1000],c2;

	a[0].day = 1;
	a[1].day = 2;
	a[2].day = 3;

	for (c = 3; c < 30; ++c) {
		a[c].day = a[c - 1].day + a[c - 2].day + a[c - 3].day;
	}

	std::cin >> N[0];
	for (c = 1; N[c - 1] != 0;++c)
	{
		std::cin >> N[c];
	}
	c2 = c;
	for (c = 0; c < c2; ++c) {
		std::cout << N[c] << "\n";
	}

	






	
}