#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int v, d;
	vector<int> fib(1010);
	fib[0] = 2;
	fib[1] = 3;
	for (int i = 2; i < 1010; i++) {
		fib[i] = fib[i-1]+fib[i-2];
		fib[i] %= 1001;
	}
	while (cin >> v >> d) {
		vector<int> f(v);
		for (int i = 0; i < v; i++) {
			f[i] = fib[i];
		}
		sort(f.begin(), f.end());
		int c = 1;
		for (int i = 1; i < v; i++) {
			if (f[i]-f[i-1]>=d) {
				c++;
			} 
		}
		cout << c << endl;
	}
	return 0;
}