#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;
}