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 <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define PI 3.14159265358979323846
#define vll vector<long long>
using namespace std;
using ll = long long;
using ld = long double;

//-------------------------------
// UnionFindのclass

class UnionFind {
private:
  ll n;
  vll P;
  void setN(ll N);
  void init();

public:
  UnionFind(ll N);
  ll root(ll x);
  void unite(ll x, ll y);
  bool same(ll x, ll y);
  ll groups();
};

// コンストラクタ
UnionFind::UnionFind(ll N) {
  setN(N);
  init();
}

// nを変更
void UnionFind::setN(ll N) { n = N; }

// Union-Find Treeを初期化する
void UnionFind::init() {
  P.clear();
  rep(i, n) { P.push_back(i); }
}

// 根の値を返す
ll UnionFind::root(ll x) {
  if (P[x] == x) { return x; }
  return (P[x] = root(P[x])); // パス圧縮しつつ返す
}

// 木を結合する（rankはとりあえず無視）
void UnionFind::unite(ll x, ll y) { P[root(x)] = root(y); }

// xとyが同じ集合にあるか判別
bool UnionFind::same(ll x, ll y) {
  if (root(x) == root(y)) {
    return true;
  } else {
    return false;
  }
}

// グループ数を返す
/*
ll UnionFind::groups() {
  unordered_set<ll> s;
  rep(i, n) { s.insert(root(i)); }
  return (ll)s.size();
}
*/

ll UnionFind::groups() {
  ll numOfGroups = 0;
  rep(i, n) {
    if (i == root(i)) { numOfGroups++; }
  }
  return numOfGroups;
}

// ----本問について----
// 問題：Fibonacci Sets
// 問題文URL：https://onlinejudge.u-aizu.ac.jp/problems/1016
// 所要時間：30分
// 学んだこと：
//  Union-Findを使えば簡単．
//  Union-Findクラスにグループ数を返すメソッドgroups()を追加しておいた．
// ------------------

// ----ここから本問のソースコード----
const ll N = 1001;

// グローバル変数（入力）
ll V, d, F[1010];

// 問題文に沿うフィボナッチ数列を作る
void makeFib() {
  F[0] = 1;
  F[1] = 2;
  for (ll i = 2; i < 1010; i++) {
    F[i] = (F[i - 1] + F[i - 2]) % N;
  }
}

void solve() {
  UnionFind u(V);
  rep(i, V) {
    for (ll j = i + 1; j < V; j++) {
      // 距離がd未満だったら同じグループに入れる（問題文とのインデックスのズレを+1で回避）
      if (abs(F[i + 1] - F[j + 1]) < d) { u.unite(i, j); }
    }
  }
  // Union-Find tree内のグループ数を出力
  cout << u.groups() << endl;
}

int main() {
  makeFib();
  while (cin >> V >> d) {
    solve();
  }
  return 0;
}

