#include <fstream>
#include <iostream>
using namespace std;
int R, D;
int rez;
void read() {
ifstream f("pascal.in");
f >> R >> D;
f.close();
}
void solve() {
// randurile 0 si 1 nu pot avea elemente divizibile cu 2, 3, 4, 5, 6 => afisam 0
if (R == 0 || R == 1)
return;
int i, p2, p3, p5, nr1, nr2, put, ok;
for (i = 1; i < (R + 2) / 2; i++) {
p2 = 0, p3 = 0, p5 = 0;
nr1 = R - i + 1, nr2 = i, put = 2;
while (nr1 >= put || nr2 >= put) {
p2 += nr1 / put;
p2 -= nr2 / put;
put *= 2;
}
nr1 = R - i + 1, nr2 = i, put = 3;
while (nr1 >= put || nr2 >= put) {
p3 += nr1 / put;
p3 -= nr2 / put;
put *= 3;
}
nr1 = R - i + 1, nr2 = i, put = 5;
while (nr1 >= put || nr2 >= put) {
p5 += nr1 / put;
p5 -= nr2 / put;
put *= 2;
}
ok = 1;
if (D % 2 == 0 && p2 < 1)
ok = 0;
if (D % 4 == 0 && p2 < 2)
ok = 0;
if (D % 3 == 0 && p3 < 1)
ok = 0;
if (D % 5 == 0 && p5 < 1)
ok = 0;
rez += ok;
}
rez *= 2;
if (R % 2 == 0)
rez--;
}
void output() {
ofstream g("pascal.out");
g << rez;
g.close();
}
int main() {
read();
solve();
output();
return 0;
}