#include<stdio.h>
int a[60]= {0};
int f(int n)
{
a[1]=1;
a[2]=2;
a[3]=3;
if(a[n]==0)
return a[n]=f(n-1)+a[n-3];
else
return a[n];
}
int main()
{
int n,i;
for(;;)
{
scanf("%d",&n);
if(n==0)
break;
printf("%d\n",f(n));
}
return 0;
}
io