#include <stdio.h>
#define SIZE 2
#define MOD 666013
void multiply_matrix(int A[SIZE][SIZE], int B[SIZE][SIZE], int result[SIZE][SIZE])
{
for (int i = 0; i < SIZE; i++) {
for (int j = 0; j < SIZE; j++) {
result[i][j] = 0;
for(int k = 0; k < SIZE; k++){
result[i][j] = (result[i][j] + 1LL * A[i][k] * B[k][j]) % MOD;
}
}
}
}
void copy_matrix(int to[SIZE][SIZE], int from[SIZE][SIZE])
{
for (int i = 0; i < SIZE; i++) {
for(int j = 0; j < SIZE; j++) {
to[i][j] = from[i][j];
}
}
}
void lgput(int matrix[SIZE][SIZE], int pow)
{
int result[SIZE][SIZE] = {{1, 0}, {0, 1}}, aux[SIZE][SIZE];
while (pow) {
if (pow & 1) {
multiply_matrix(result, matrix, aux);
copy_matrix(result, aux);
}
multiply_matrix(matrix, matrix, aux);
copy_matrix(matrix, aux);
pow >>= 1;
}
copy_matrix(matrix, result);
}
int main(void)
{
int n, first_element;
int matrix[SIZE][SIZE] = {{1, 1}, {1, 0}};
scanf("%d", &n);
first_element = 1;
lgput(matrix, n - 1);
printf("%d\n", first_element * matrix[0][0]);
return 0;
}