#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e7;
string s;
int k,t=1,u=0,kkk=0;
bool f=true;
struct xd{
string st;
int n;
}a[MAXN];
int main(){
cin>>s>>k;
for(int i=k-1;i<s.size();i++)
{
if(i==k-1)
{
a[1].n=1;
for(int j=0;j<k;j++)
{
a[1].st[j]=s[j];
}
continue;
}
string r;
u=0;
for(int j=i-k+1;j<=i;j++)
{
r[u]=s[j];
u++;
}
for(int j=1;j<=t;j++)
{
if(r==a[j].st)
{
a[j].n++;
f=false;
break;
}
}
if(f==true)
{
t++;
a[t].n=1;
a[t].st=r;
}
}
for(int i=1;i<=t;i++)
{
if(a[i].n>kkk) kkk=a[i].n;
}
cout<<kkk;
}
this