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