#include<bits/stdc++.h>
using namespace std;
inline long long read()
{
long long x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9')
{
if(ch=='-')
f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9')
{
x=x*10+ch-'0';
ch=getchar();
}
return x*f;
}
inline void write(long long x)
{
if(x<0)
putchar('-'), x=-x;
if(x>=10)
write(x/10);
putchar(x%10+'0');
}
long long n,k;
map<__int128,bool> mp;
inline bool chk(long long x)
{
long long y=sqrt(x);
return y*y==x;
}
inline __int128 power(__int128 x,long long y)
{
__int128 sum=1;
while(y--)
sum*=x;
return sum;
}
int main()
{
//freopen("power.in","r",stdin);
//freopen("power.out","w",stdout);
//std::ios::sync_with_stdio(false);
n=read();
k=read();
if(k==1)
write(n), putchar('\n');
else
{
if(k==2)
{
long long ans=sqrt(n);
for(long long i=3;i<=60;++i)
{
for(long long j=2;;++j)
{
__int128 x=power(j,i);
if(x>n)
break;
if(i==3&&chk(x))
continue;
if(i!=3&&(chk(x)||(mp.find(x)!=mp.end())))
continue;
++ans;
mp[x]=1;
}
}
write(ans), putchar('\n');
}
else
{
if(k>61)
{
cout<<1<<endl;
return 0;
}
long long ans=0;
for(long long i=k;i<=61;++i)
{
for(long long j=1;;++j)
{
__int128 x=power(j,i);
if(x>n)
break;
if(mp.find(x)!=mp.end())
continue;
++ans;
mp[x]=1;
}
}
write(ans), putchar('\n');
}
}
return 0;
}