#include<stdlib.h>
p(int*a,int*b){return*a-*b;}
int main () {
int f[1001];
int F[1001];
int N,i,V,d,count;
N=1001;
f[0]=2;
f[1]=3;
for(;~scanf("%d%d",&V,&d);){
  count = 1;
  for(i=2;i<V;i++)F[i]=(F[i-1]+F[i-2])%N;}
 for(i=0;i<V;i++)f[i]=F[i];
  qsort(F,V,4,p);
  for(i=1;i<V;i++)
    if(F[i]-F[i-1]>d-1)
      count++;
  printf( "%d\n" , count);
 }
 return 0;
}