#include using namespace std; class UnionFind { private: int sz; vector par, siz; public: UnionFind() {} UnionFind(int n) : sz(n), par(sz), siz(sz, 1) { iota(par.begin(), par.end(), 0); } int root(int x) { if (par.at(x) == x) return x; else return par.at(x) = root(par.at(x)); } void unit(int x,int y) { x = root(x), y = root(y); if (x == y) return; if (siz.at(x) < siz.at(y)) swap(x, y); par.at(y) = x; siz.at(x) += siz.at(y); } int size(int x) { x = root(x); return siz.at(x); } bool same(int x, int y) { return root(x) == root(y); } }; int main() { int N, P; cin >> N >> P; UnionFind UF(N + 1); for (int i = 2; i <= N; i++) { for (int j = i + i; j <= N; j += i) UF.unit(j - i, j); } cout << UF.size(P) << "\n"; }