#include <cstdio>
#include <algorithm>
using namespace std;
int fib[1004], cfib[1001];
int V, d;

void init() {
    fib[0] = 0, fib[1] = 1;
    for (int i = 2; i <= 1003; i++) {
        fib[i] = (fib[i-1]+fib[i-2]) % 1001;
    }
}

void solve() {
    for (int i = 0; i <= V; i++) cfib[i] = 0;
    for (int i = 0; i < V; i++) {
        cfib[i] = fib[i+3];
    }
    sort(cfib, cfib+V);
    int sum = 1;
    for (int i = 1; i <= V; i++) {
        if (cfib[i] - cfib[i-1] >= d) sum++;
    }
    printf("%d\n", sum);
}

int main() {
    init();
    while(scanf("%d %d", &V, &d) != EOF) {
        solve();
    }
    return 0;
}

