#pragma region #pragma GCC target("avx2") #pragma GCC optimize("03") #pragma GCC optimize("unroll-loops") #include using namespace std; typedef long double ld; typedef long long ll; typedef unsigned long long ull; #define endl "\n" #define FOR(i,a,b) for(int i=(a);i<=(b);i++) #define rep(i,n) for(int i=0;i<(n);i++) #define PII pair #define PLL pair #define ALL(x) (x).begin(), (x).end() constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1; templateinline bool chmax(T &a, const T &b) { if (ainline bool chmin(T &a, const T &b) { if (b factorize(int n) { map ans; for(int i=2;i*i<=n;i++) { while(n%i==0) { ans[i]++; n /= i; } } if(n!=1) ans[n]++; return ans; } vector prime(int n) { vector isprime(n+1, true); isprime[0] = false; isprime[1] = false; for(int i=2;i<=n;i++) { if(!isprime[i]) continue; for(int j=i+i; j<=n; j+=i) isprime[j] = false; } return isprime; } int main(){ cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15); int n,p; cin >> n >> p; if(p==1) { cout << 1 << endl; return 0; } auto isprime = prime(n); if(isprime[p] and n==p) { cout << 1 << endl; return 0; } int ans = 1; for(int i=n/2+1; i<=n; i++) { // cout << i << endl; ans += isprime[i]; } cout << n-ans << endl; return 0; }