#include <stdio.h>

#define SIZE (150)
#define N (1001)

void swap(int *a, int *b)
{
	int tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}

void makeHeap(int *dat, int size, int oya)
{
	int i;		/// ½§ä
	int oidx;	/// eÌY¦Û¶
	int oval;	/// eÌlÛ¶
	int ko;		/// qÌY¦

	oidx = oya; // eÌY¦ðÛ¶
	oval = dat[oidx]; // eÌlðÛ¶
	ko = oidx + oidx + 1; // ¶ÌqÌY¦ðÛ¶
	while(ko < size) // ±ÌY¦ªf[^¢ÌêJèÔ·
	{
		if((ko+1 < size) && (dat[ko] < dat[ko+1])) ko++; // EÌqªå«¢
		if(oval >= dat[ko]) break; // eªå«¢, »±ÅI¹
		
		dat[oidx] = dat[ko]; // eÉêÔå«¢qÌlðãü
		oidx = ko; // »ÌqÌY¦ðeÆ·é
		ko = oidx + oidx + 1; // eÆµ½qÌqðßé
	}
	dat[oidx] = oval; // Û¶µÄ¢½eÌlðãü
}

int hsort(int *dat, int size)
{
	int oya;
	int sz = size;

	for(oya=(int)((size-2)/2); oya >= 0; oya--) {
		makeHeap(dat, sz, oya);
	}
	while(sz > 0) {
		sz--;
		swap(&dat[0], &dat[sz]);
		makeHeap(dat, sz, 0);
	}

	return 0;
}

int main(void)
{
	int fib, fib1, fib2;
	char input[8];
	int node[SIZE];
	short cnt;
	short v, d; /// üÍ v, d
	short i, j; /// ½§ä{i, j}
	short scnt; /// TCYÌJEg

	///double st, pt;

	while(gets(input)) {
		if(input[0] == '\0') break;
		sscanf(input, "%d%d", &v, &d);
		///st = gettime();
		scnt = 1;
		fib1 = 1; fib2 = 2;
		node[0] = fib2;
		for(i=2; i <= v; i++) {
			fib = (fib2 + fib1) % N;
			node[scnt++] = fib;
			fib1 = fib2; fib2 = fib;
		}

		hsort(node, scnt);
		cnt = 1; i = 0;
		for(j=i+1; j < scnt; j++) {
			if(0 > (node[j]-node[i]) || (node[j]-node[i]) >= d){
				cnt++;
			}
			i = j;
		}
		
		printf("%d\n", cnt);
	}

	return 0;
}