#include <bits/stdc++.h>
using namespace std;
int main()
{
char a[]=“abbceddd”;
int k = 3;
int len=-1;
int i=0;
int cnt=0;
int freq[26]={0};
for(int j=0;j!=’\0’;j++)
{
int x = freq[a[j]-‘a’];
x++;
if(x==1)
{
cnt++;
}
while(cnt>k)
{
freq[a[i]-'a']--;
if(freq[a[i]-'a']==0)
{
cnt--;
}
i++;
}
if(cnt==k)
{
len=max(len,j-i+1);
}
}
cout<<len;
return 0;
}