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 <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define DBG(X) cout<<" "<<#X<<" : "<<X<<endl
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;

const int INF = 1e9;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
const ll LINF = 1e18;

struct Input
{
	int n;char c;char str[10010];string s;ll l;double d;
	int nextInt(){scanf("%d", &n);return n;}
	ll nextLong(){scanf("%lld", &l);return l;}
	double nextDouble(){scanf("%lf", &d);return d;}
	char nextChar(){scanf("%c", &c);return c;}
	string next(){scanf("%s", str);return string(str);}
	string nextLine(){getline(cin, s);return s;}
};
Input in;

const int Mod = 1001;

ll fib[100010];
ll calcFib(int n){
	if(n == 0 || n==-1) return 1LL;
	if(fib[n]>0) return fib[n];
	return fib[n] = (calcFib(n-1)+calcFib(n-2))%Mod;
}

struct UFT{	//O(loga(n))
	int n;
	vi d, r;
	UFT(int n) : n(n), d(n, -1), r(n, 0){};
	int root(int i){
		if(d[i] < 0) return i;
		return d[i] = root(d[i]);
	}
	bool same(int x, int y){
		return root(x) == root(y);
	}
	bool unite(int x, int y){
		x = root(x);
		y = root(y);
		if(x == y) return false;

		if(r[x] < r[y]) swap(x, y);
		else if(r[x] == r[y]) r[x]++;
		d[x] += d[y];
		d[y] = x;
		return true;
	}
	int size(int i){
		return -d[root(i)];
	}
};



int main(){
	calcFib(1010);
	int v, d;
	while(scanf("%d%d", &v, &d) != EOF){
		UFT uft(v+1);
		int ans = 0;
		for(int i= 1; i <= v; i++){
			for(int j = i + 1; j <= v; j++){
				if(abs(fib[i]-fib[j])<d){
					uft.unite(i, j);
				}
			}
		}
		set<int> st;
		for(int i = 1; i <= v; i++){
			st.insert(uft.root(i));
		}
		printf("%d\n", (int)st.size());
	}
}