#include "bits/stdc++.h" #define in std::cin #define out std::cout #define rep(i,N) for(LL i=0;i> N >> P; LL ans; if (P == 1) ans = 1; else { ans = N - 1; for (LL i = N / 2 + 1; i <= N; ++i) { bool flag = true; for (LL j = 2; j * j <= i; ++j) { if (i % j == 0) { flag = false; break; } } if (flag) { --ans; if (i == P) { ans = 1; break; } } } } out << ans << std::endl; }