#include <iostream>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

using namespace std;

typedef long long ll;

const int N = 1001;
int V, d;

ll f[N + 1];

int main(void) {
    f[0] = 1L; f[1] = 2L;
    for(int i = 2; i <= N; i++) {
        f[i] = (ll) ((f[i - 2] % N) + (f[i - 1] % N)) % N;
    }
    while(~scanf("%d %d", &V, &d)) {
        vector<ll> tmp;
        for(int i = 1; i <= V; i++) {
            tmp.push_back((ll)f[i]);
        }
        int ans = 1; sort(tmp.begin(), tmp.end());
        for(int i = 1; i < (int) tmp.size(); i++) {
            if(tmp[i] - tmp[i - 1] >= d) ans++;
        }
        printf("%d\n", ans);
    }
    return 0;
}