#include <fstream>
#define DIM 2
#define MOD 666013
#define LL long long
using namespace std;
LL a[DIM][DIM] {
{1,1},
{1,0}
};
LL Id[DIM][DIM] {
{1,0},
{0,1}
};
LL p[DIM][DIM], aux[DIM][DIM];
void copiere(LL a[DIM][DIM], LL b[DIM][DIM], LL n) {
for (LL i=0;i<n;i++)
for (LL j=0;j<n;j++)
a[i][j] = b[i][j];
}
void produs(LL a[DIM][DIM], LL b[DIM][DIM], LL c[DIM][DIM], LL n) {
/// C = A X B
LL i, j, k;
for (i=0;i<n;i++)
for (j=0;j<n;j++) {
c[i][j] = 0;
for (k=0;k<n;k++) {
c[i][j] += a[i][k]*b[k][j];
c[i][j] %= MOD;
}
}
/// C[i][j] = LiA X CjB
}
LL n;
int main () {
ifstream fin ("kfib.in");
ofstream fout("kfib.out");
fin>>n;
n -= 2;
/// p = 1;
copiere(p, Id, 2);
while (n!=0) {
if (n%2 == 1) {
/// p = p*a;
produs(p, a, aux, 2);
copiere(p, aux, 2);
}
/// a = a*a;
produs(a, a, aux, 2);
copiere(a, aux, 2);
n /= 2;
}
fout<<(p[0][0] + p[0][1]) % MOD;
return 0;
}