Fibonacci number f(i) appear in a variety of puzzles in nature and math, including packing problems, family trees or Pythagorean triangles. They obey the rule f(i) = f(i - 1) + f(i - 2), where we set f(0) = 1 = f(-1).

Let V and d be two certain positive integers and be N ≡ 1001 a constant. Consider a set of V nodes, each node i having a Fibonacci label F[i] = (f(i) mod N) assigned for i = 1,..., V ≤ N. If |F(i) - F(j)| < d, then the nodes i and j are connected.

Given V and d, how many connected subsets of nodes will you obtain?

<image>

Figure 1: There are 4 connected subsets for V = 20 and d = 100.

Constraints

* 1 ≤ V ≤ 1000
* 1 ≤ d ≤ 150

Input

Each data set is defined as one line with two integers as follows:

Line 1: Number of nodes V and the distance d.

Input includes several data sets (i.e., several lines). The number of dat sets is less than or equal to 50.

Output

Output line contains one integer - the number of connected subsets - for each input line.

Example

Input

5 5
50 1
13 13


Output

2
50
8
#include<iostream>
#include<algorithm>
using namespace std;

const int MAX_N = 1001; //要素の個数の最大値を1001とする
int f[MAX_N + 1] = {1, 2};//最初に2,

int par[MAX_N];  //ノードの親を格納
int rank[MAX_N]; //木の高さ

/*フィボナッチ数列を計算して、配列fに順に入れる*/
void fib_init(){
  for(int i = 2; i < MAX_N+1; i++){
    f[i] = (f[i-1] + f[i-2]) % MAX_N;
  }
}

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

/*xのルートが何かを見つける*/
int find(int x){
  if(par[x] == x){ 
    //自分がルート
    return x;
  }else{
    //自分の親がいるなら、その親について再帰的に探す
    return par[x] = find(par[x]);
  }
}

/*集合を連結させる*/
void unite(int x, int y){
  x = find(x);
  y = find(y);
  //xとyのルートが同じ、つまり既に連結しているなら何もしない
  if(x == y) return;

  //ランク(高さ)が低いもののルートを、高いもののルートに繋げる
  if(rank[x] < rank[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(rank[x] == rank[y]) rank[x]++;
  }
}

/*２つのノードのルートが同じであるかを調べる*/
bool same(int x, int y){
  return find(x) == find(y);
}

/*------------------------------------------*/
int main()
{
  //フィボナッチ数列を設定する{1, 2, 3, 5, 8, 13,...}
  fib_init();

  //v=要素の個数, |f(i) - f(j)| < d の条件のd
  int v, d; 

  while(cin >> v >> d){
    init(v);
    int memo[MAX_N+1] = {0}; //集合を数えるときに使う

    //全要素の２つの組み合わせを調べ、|f(i) - f(j)| < dを満たしているなら連結する
    for(int i = 0; i < v; i++){
      for(int j = i + 1; j < v; j++){
	if(abs(f[i] - f[j]) < d){
	  unite(i, j); // if all pair nod 
	}
      }
    }
    
    //集合の数を数える
    int ans = 0;
    for(int i = 0; i < v; i++){
      int root = find(i); //rootに全てのノードのルートを入れる
      if(memo[root] == 0){
	memo[root] = 1; //初めてrootにルートを入れるときだけmemoに1を入れる
	ans++; //そのときansに1足す
      }
    }
    //出力
    cout << ans << endl;
  }
}