#include #include int main() { std::size_t N, P; std::cin >> N >> P; std::vector isprime(N + 1, true); std::size_t L = N - 1; for (std::size_t i = 2; i <= N; i++) { if (not isprime[i]) { continue; } if (2 * i > N) { L--; } for (std::size_t j = 2; i * j <= N; j++) { isprime[i * j] = false; } } std::cout << (P == 1 or (2 * P > N and isprime[P]) ? 1 : L) << std::endl; return 0; }