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