#include<iostream>
#include<cstring>
using namespace std;
#define reg register int
#define ull unsigned long long
int cnt[125];
ull L,maxi=0;
string s;
int main()
{
cin>>s>>L;
for(reg i=0;i<s.length();i++)
cnt[s[i]]++;
for(reg i=45;i<=123;i++)
if(cnt[i]>maxi)maxi=cnt[i];
ull ans=0,aL=s.length()-maxi,bL=maxi;
while(aL+bL<L)
{
bL*=2;
ans++;
}
cout<<ans;
return 0;
}
不知道哪里出了问题,求改正。(码风巨丑请谅解qwq)