#include<bits/stdc++.h>
using namespace std;
main()
{
string a,ans,b;
int k,t,m;
while(cin>>k>>a)
{
int x[a.length()-k];
for(int l=0;l<=a.length()-k;l++)
{
ans="";m=0;
if(a[l]-65<=25) t=0;
else t=1;
for(int i=l;i<=a.length()-k;i+=k)
{
if(m) break;
b=a.substr(i,k);
//cout<<b;
for(int j=0;j<k;j++)
{
if(t==1 and b[j]-65<=25)
{
m=1;break;
}
else if(t==0 and b[j]-65>25)
{
m=1;break;
}
else if(j==k-1) ans+=b;
}
if(t==0) t=1;
else t=0;
}
x[l]=ans.length();//cout<<endl;
//cout<<ans<<endl;
}
int max=(*max_element(x,x+a.length()-k+1));
cout<<max<<endl;
}
}