#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; --p; Unionfind uf(n); rep(i,n)rep(j,n){ if(gcd(i+1,j+1)==1) continue; uf.unite(i,j); } cout << uf.size(p) << endl; return 0; }