// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

class UFTree {
  std::vector<int> data, rank, _size;

public:
  UFTree(const int &n) : data(n), rank(n), _size(n, 1) { iota(all(data), 0); }

  int root(const int &x) { return data[x] == x ? x : data[x] = root(data[x]); }

  bool same(const int &a, const int &b) { return root(a) == root(b); }

  void unite(int a, int b) {
    a = root(a), b = root(b);
    if (a == b) return;
    if (rank[a] < rank[b]) std::swap(a, b);
    data[b] = a;
    _size[a] += _size[b];
    if (rank[a] == rank[b]) rank[a]++;
  }

  int sizeOf(int x) { return _size[root(x)]; }
};

template<int mod> struct modint {
  int v;
  modint(int a = 0) : v(((a % mod) + mod) % mod) {}
  modint operator+(const modint<mod> &b) const { return (v + b.v) % mod; }
  modint operator-(const modint<mod> &b) const { return (v - b.v + mod) % mod; }
  modint operator*(const modint<mod> &b) const { return (v * b.v) % mod; }
  modint operator/(const modint<mod> &b) const { return (v * b.inv().v) % mod; }
  modint<mod> inv() const { return pow(mod - 2); }
  modint<mod> pow(int t) const {
    modint e = v, c = 1;
    while (t) {
      if (t & 1) c *= e;
      t >>= 1;
      e *= e;
    }
    return c;
  }
  explicit operator int() { return v; }
  friend bool operator==(const modint<mod> &a, const modint<mod> &b) { return a.v == b.v; }
  friend bool operator!=(const modint<mod> &a, const modint<mod> &b) { return a.v != b.v; }
  friend modint<mod> &operator+=(modint<mod> &a, const modint<mod> &b) { return a = a + b; }
  friend modint<mod> &operator-=(modint<mod> &a, const modint<mod> &b) { return a = a - b; }
  friend modint<mod> &operator*=(modint<mod> &a, const modint<mod> &b) { return a = a * b; }
  friend modint<mod> &operator/=(modint<mod> &a, const modint<mod> &b) { return a = a / b; }
  friend std::ostream &operator<<(std::ostream &os, const modint<mod> &a) { return os << a.v; }
  friend std::istream &operator>>(std::istream &is, modint<mod> &a) {
    int v;
    is >> v;
    a = v;
    return is;
  }
};

template<typename Integral = int> Integral fibonacci(const int &n) {
  static std::vector<Integral> dp = {1, 2};
  int prev = dp.size();
  if (prev < n + 1) {
    dp.resize(n + 1);
    loop(i, prev, dp.size()) dp[i] = dp[i - 1] + dp[i - 2];
  }
  return dp[n];
}

main {
  int v, d;
  while (cin >> v >> d) {
    UFTree uf(v + 1);
    loop(i, 1, v + 1) loop(j, i + 1, v + 1) {
      if (abs(fibonacci<modint<1001>>(i).v - fibonacci<modint<1001>>(j).v) < d) uf.unite(i, j);
    }
    int c = 0;
    loop(i, 1, v + 1) c += uf.root(i) == i;
    cout << c << endl;
  }
}

Measured memory_bytes: 3036