#include<bits/stdc++.h>
#include <cstdio>
#define int long long
const int N = 1e6 + 10;
using namespace std;
int n, k, ans = 0;
int QAQ (int a,int b) {
int ans = 1;
while (b) {
if (b & 1) ans = ans * a;
b >>= 1;
a *= a;
}
return ans;
}
void solve () {
cin >> n >> k;
int x = 0;
if (k == 1) return cout << n, void();
set <int> a;
for (int i = 2; i * i * i <= n; ++i) {
int temp = i * i;int m = 2;
while (temp <= n/i) {
temp *= i, m++;
if (m < k) continue;
if (a.count(temp)) continue;
if ((long long) sqrtl(temp) * sqrtl(temp) == temp) x++;
a.insert(temp);
ans++;
}
}
if (k >= 3) cout << ans + 1;
else cout << (long long) sqrtl(n) + ans - x;
}
signed main() {
freopen("power.in","r",stdin);
freopen("power.out","w",stdout);
solve();
return 0;
}