#include<bits/stdc++.h>
using namespace std;
#define MOD 1001
int main(){
  vector<int> fib;
  int i,j,k;
  fib.push_back(2);
  fib.push_back(3);
  for(i=2;i<1050;i++) fib.push_back((fib[i-2]+fib[i-1])%MOD);
  int n,d;
  while(cin>>n>>d){
    int o=1;
    vector<int> v;
    for(i=0;i<n;i++) v.push_back(fib[i]);
    sort(v.begin(),v.end());
    for(i=1;i<n;i++){
      if(abs(v[i]-v[i-1])>=d) {
	o++;
      }
    }
    cout << o << endl;
  }
  return 0;
}