#include <cstdio>
#include <iostream>
#include <string>
using namespace std;

int main(){
  int i,j,v,d,a[10002],n,c,tmp;

  while(scanf("%d%d",&v,&d) != EOF){
    c = 1;
    a[0] = 1;
    a[1] = 2;
    
    for(i=2;i<=v;i++) a[i] = (a[i-1] + a[i-2]) % 1001;
    
    for(i=v;i>1;i--){
      for(j=1;j<i;j++){
	if(a[j+1] < a[j]){
	  tmp = a[j];
	  a[j] = a[j+1];
	  a[j+1] = tmp;
	}
      }
    }
    
    for(i=2;i<=v;i++){
      if(a[i] - a[i-1] >= d) c++;
    }
    
    cout << c << endl;
    
  }
  return 0;
}