#include "iostream"
#include "cstdio"
using namespace std;
class matrix
{
public:
int a[][];
matrix()
{
a[][]=a[][]=a[][]=;
a[][]=;
}
};
matrix multi(matrix a,matrix b)
{
matrix temp;
int i,j,k;
for(i=;i<;i++)
for(j=;j<;j++)
{
temp.a[i][j]=;
for(k=;k<;k++)
temp.a[i][j]+=(a.a[i][k]*b.a[k][j]);
temp.a[i][j]%=;
}
return temp;
}
matrix power(int n)
{
matrix temp,s;
temp.a[][]=temp.a[][]=;
temp.a[][]=temp.a[][]=;
while(n!=)
{
if(n%!=)
temp=multi(temp,s);
s=multi(s,s);
n=n/;
}
return temp;
}
int main()
{
int n;
while(~scanf("%d",&n)&&(n!=-))
{
matrix t=power(n);
cout<<t.a[][]<<endl;
}
return ;
}
#include "iostream"
#include "cstdio"
using namespace std;
#define MOD 1000000009
#define LL long long
class matrix
{
public:
LL a[][];
matrix()
{
a[][]=a[][]=a[][]=;
a[][]=;
}
};
matrix multi(matrix a,matrix b)
{
matrix temp;
LL i,j,k;
for(i=;i<;i++)
for(j=;j<;j++)
{
temp.a[i][j]=;
for(k=;k<;k++)
temp.a[i][j]+=(a.a[i][k]*b.a[k][j]);
temp.a[i][j]%=MOD;
}
return temp;
}
matrix power(LL n)
{
matrix temp,s;
temp.a[][]=temp.a[][]=;
temp.a[][]=temp.a[][]=;
while(n!=)
{
if(n%!=)
temp=multi(temp,s);
s=multi(s,s);
n=n/;
}
return temp;
}
int main()
{
LL n;
while(~scanf("%lld",&n)&&(n!=-))
{
matrix t=power(n);
cout<<t.a[][]<<endl;
}
return ;
}