#include <bits/stdc++.h>
using namespace std;
#define int long long
long long n,k,ans;
map<int,bool> mp;
signed main() {
cin >> n >> k;
if(k==1){
cout << n;
exit(0);
}
for(int i = max(k,3ll);i <= 63;i ++){
for(int j = 1;pow(j,i) <= n;j ++){
int x=pow(j,i);
if(!mp[x] && ((int)sqrt(x)*(int)sqrt(x)!=x || k!=2)){
mp[x]=1,ans++;
}
}
}
if(k==2) ans+=sqrt(n);
cout << ans;
return 0;
}
WA80,死法不明
