#include <bits/stdc++.h>
using namespace std;
int main()
{
long long f[100] = {0, 1, 2, 4, 7};
for (int i = 5; i < 100; i++)
{
f[i] = f[i - 1] + f[i - 2] + f[i - 3];
}
int n;
while (cin >> n)
{
if (n == 0)
break;
printf("%lld\n", f[n]);
}
return 0;
}