#include <iostream>
using namespace std;
#define ull unsigned long long
struct matrix {
int x11, x12, x21, x22;
matrix() {
x11 = 1, x12 = 0, x21 = 0, x22 = 1;
}
matrix(int a, int b, int c, int d) {
x11 = a, x12 = b, x21 = c, x22 = d;
}
matrix mul(matrix M) {
int a, b, c, d;
a = (x11*M.x11 + x12*M.x21) % 1000;
b = (x11*M.x12 + x12*M.x22) % 1000;
c = (x21*M.x11 + x22*M.x21) % 1000;
d = (x21*M.x12 + x22*M.x22) % 1000;
return matrix(a,b,c,d);
}
void print() {
cout << x11 << " " << x12 << endl << x21 << " " << x22 << endl;
}
};
matrix power(matrix A, ull n) {
if (n == 0)
return matrix();
if (n == 1)
return A;
if (n % 2 == 0)
return power(A.mul(A), n/2);
if (n % 2 == 1)
return A.mul(power(A.mul(A), n/2));
}
int main() {
ull n;
int tmp, x, y;
matrix A(1,1,1,0), B;
while (cin >> n) {
B = power(A,n-1);
cout << (B.x21 + B.x22) % 1000 << endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwojZGVmaW5lIHVsbCB1bnNpZ25lZCBsb25nIGxvbmcKCnN0cnVjdCBtYXRyaXggewoJaW50IHgxMSwgeDEyLCB4MjEsIHgyMjsKCQoJbWF0cml4KCkgewoJCXgxMSA9IDEsIHgxMiA9IDAsIHgyMSA9IDAsIHgyMiA9IDE7Cgl9CgkKCW1hdHJpeChpbnQgYSwgaW50IGIsIGludCBjLCBpbnQgZCkgewoJCXgxMSA9IGEsIHgxMiA9IGIsIHgyMSA9IGMsIHgyMiA9IGQ7Cgl9CgkKCW1hdHJpeCBtdWwobWF0cml4IE0pIHsKCQlpbnQgYSwgYiwgYywgZDsKCQlhID0gKHgxMSpNLngxMSArIHgxMipNLngyMSkgJSAxMDAwOwoJCWIgPSAoeDExKk0ueDEyICsgeDEyKk0ueDIyKSAlIDEwMDA7CgkJYyA9ICh4MjEqTS54MTEgKyB4MjIqTS54MjEpICUgMTA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