#include<stdio.h>
int main()
{
long long a[71];
int b[71];
a[0]=1;a[1]=2;a[2]=4;
int i=0,j;
while(scanf("%d",&b[i])&&b[i]!=0)
{
if(b[i]>3)
{
for(j=3;j<b[i];j++)
a[j]=a[j-1]+a[j-2]+a[j-3];}
i++;
}
for(i=0;b[i]!=0;i++)
printf("%lld\n",a[b[i]-1]);
}