#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("smen.in");
ofstream fout("smen.out");
int n;
unsigned long long sm;
unsigned long long numere(int x)
{
unsigned long long rv=3;
int i=0;
while(x-- > 0)
{
i=i+1;
rv=(rv*rv/(i+2)+rv*i+i+1)%666013;
}
return rv;
}
int main()
{
fin>>n;
sm=numere(n);
fout<<sm;
return 0 ;
}