// Author: Ivan Kazmenko (gassa@mail.ru)
module solution;
import std;

immutable int a =       1;
immutable int p = 618_023;
immutable int m = 999_983;

int solve (int n, int s)
{
	auto v = new bool [m];
	int total = 0;
	foreach (i; 0..n)
	{
		s = (cast (long) (s) * p + a) % m;
		debug {writeln (s);}
		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;
}

void main ()
{
	int n, s;
	while (readf !(" %s %s") (n, s) > 0)
	{
		writeln (solve (n, s));
	}
}
