#include<iostream>
#include<vector>
#include<algorithm>
#define N 1001
using namespace std;

int main(){
  int v,d,f[2000];

  f[0] = 1;
  f[1] = 2;
  for(int i=2;i<=N;i++)f[i] = (f[i-1] + f[i-2])%N;

  while(cin >> v >> d){
    vector<int> vec;
    for(int i=1;i<=v;i++)vec.push_back(f[i]);
    sort(vec.begin(),vec.end());

    int ans = 1;
    for(int i=0;i<v-1;i++){
      if(vec[i+1] - vec[i] >=d)ans++;
    }
    cout << ans << endl;
  }
}