#include<cstring>
#include<set>
#include<cstdio>
using namespace std;

int par[1010], h[1010];

inline void init(int n){
  for(int i=0;i<n;i++){
    par[i] = i;
    h[i] = 0;
  }
}

inline int find(int x){
  if(par[x] == x)return x;
  return par[x] = find(par[x]);
}

inline bool same(int a,int b){
  return find(a) == find(b);
}

inline void unite(int a, int b){
  a = find(a); b = find(b);
  if(same(a,b))return;

  if(h[a] < h[b])par[a] = b;
  else{
    par[b] = a;
    if(h[a] == h[b])h[a]++;
  }
}

const int N = 1001;

int main(){
  int v,d,f[1010];
  f[0] = f[1] = 1;
  for(int i=0;i<N;i++)f[i+2] = (f[i] + f[i+1]) % N;

  while(scanf("%d%d",&v,&d)!=EOF){
    init(v);
    for(int i=0;i<v;i++){
      for(int j=i+1;j<v;j++){
	int tmp = f[i+2]-f[j+2];
	if(tmp<0)tmp *= -1;
	if(tmp < d)unite(i,j);
      }
    }

    bool use[1010] = {};
    int ans = 0;
    for(int i=0;i<v;i++){
      if(!use[find(i)]){
	ans++;
	use[par[i]] = true;
      }
    }

    printf("%d\n",ans);
  }
}