#include #define rep(i,n) for(int i=0;i ; const int INF = 1e9; const int MOD = 1000000007; ll gcd(ll i,ll j){ if(j == 0) return i; return gcd(j,i%j); } struct Unionfind{ vector parents; int m; Unionfind(int n):parents(n,-1){ m = n; } int find(int x){ if(parents.at(x) < 0){ return x; }else{ parents.at(x) = find(parents.at(x)); return parents.at(x); } } void unite(int x,int y){ x = find(x); y = find(y); if(x==y) return; if(parents.at(x) > parents.at(x))swap(x,y); parents.at(x) += parents.at(y); parents.at(y) = x; } int size(int x){ return -parents.at(find(x)); } bool same(int x,int y){ return find(x) ==find(y); } vector members(int x){ int root = find(x); vector A; for(int i=0;i> n >> p; Unionfind uf(n+5); vector f(n+5,0); f[0] = f[1] = -1; for(int i=2;i<=n;i++){ if(f[i]) continue; for(int j=i;j<=n;j+=i){ f[j] = i; if(j==i) continue; uf.unite(j,j-i); } } cout << uf.size(p) << endl; return 0; }