#include #include #include #include #include #include #include #include #define _fetch(_1, _2, _3, _4, name, ...) name #define rep2(i, n) rep3(i, 0, n) #define rep3(i, a, b) rep4(i, a, b, 1) #define rep4(i, a, b, c) for (int i = int(a); i < int(b); i += int(c)) #define rep(...) _fetch(__VA_ARGS__, rep4, rep3, rep2, _)(__VA_ARGS__) using namespace std; using i64 = long long; using u32 = unsigned; using u64 = unsigned long long; using f80 = long double; pair, vector> prime_counts(u64 n) { u64 v = sqrt(n); vector smalls(v + 1), larges(v + 1); rep(i, 1, v + 1) smalls[i] = i - 1, larges[i] = u64(n / i) - 1; rep(i, 2, v + 1) if (smalls[i] > smalls[i - 1]) { u64 c = smalls[i - 1]; u64 q = u64(i) * i; rep(j, 1, min(v, n / q) + 1) { u64 d = j * i; larges[j] -= (d <= v ? larges[d] : smalls[n / d]) - c; } for (u64 j = v; j >= q; --j) smalls[j] -= smalls[j / i] - c; } return make_pair(smalls, larges); } vector big_omegas(u64 N) { u32 sqrt_N = sqrt(N); vector cnts(64 - __builtin_clzll(N)); cnts[0] += 1; if (N > 1) { auto pi = prime_counts(N); auto& smalls = pi.first, &larges = pi.second; auto primes = vector(); rep(i, 2, sqrt_N + 1) if (smalls[i] > smalls[i - 1]) primes.push_back(i); primes.push_back(sqrt_N + 1); function< void(u64, int, int) > rec = [&](u64 n, int i, int c) { cnts[c + 1] += (n > sqrt_N ? larges[N / n] : smalls[n]) - smalls[primes[i] - 1]; rep(j, i, primes.size()) { u32 p = primes[j]; if (u64(p) * p > n) break; rec(n / p, j, c + 1); } }; rec(N, 0, 0); } return cnts; } vector omegas(u64 N) { u32 sqrt_N = sqrt(N); vector cnts(64 - __builtin_clzll(N)); auto pi = prime_counts(N); auto& smalls = pi.first, &larges = pi.second; auto primes = vector(); rep(i, 2, sqrt_N + 1) if (smalls[i] > smalls[i - 1]) primes.push_back(i); primes.push_back(sqrt_N + 1); function< void(u64, int, int, int) > rec = [&](u64 n, int i, int p, int c) { cnts[c + 1] += (n > sqrt_N ? larges[N / n] : smalls[n]) - smalls[p]; cnts[c] += 1; rep(j, i, primes.size()) { int q = primes[j]; if (u64(q) * q > n) break; rec(n / q, j, q, c + (p != q)); } }; rec(N, 0, 1, 0); return cnts; } void solve() { u64 N, K; while (~scanf("%llu %llu", &N, &K)) { auto cnts = omegas(N); u64 ans = (K < cnts.size() ? cnts[K] : 0); printf("%llu\n", ans); } } int main() { clock_t beg = clock(); solve(); clock_t end = clock(); fprintf(stderr, "%.3f sec\n", double(end - beg) / CLOCKS_PER_SEC); return 0; }