// Author: Ivan Kazmenko (gassa@mail.ru)
#include <bits/stdc++.h>
using namespace std;

int const a =       1;
int const p = 618'023;
int const m = 999'983;

int solve (int n, int s)
{
	auto v = vector <bool> (m);
	int total = 0;
	for (int i = 0; i < n; i++)
	{
		s = int ((int64_t (s) * p + a) % m);
		int cur = 0;
		for (int x = 0; x + x < s; x++)
		{
			cur += v[x] & v[s - x];
		}
		if (!(cur & 1))
		{
			v[s] = true;
			total += 1;
		}
	}
	return total;
}

int main ()
{
	int n, s;
	while (cin >> n >> s)
	{
		cout << solve (n, s) << endl;
	}
	return 0;
}
