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