#include <iostream>
using namespace std;
#include <bits/stdc++.h>


int main() {
	// your code goes here
	
	 string s;
	 cin>>s;
	 int current_length=0,max_length=INT_MIN;
	 
	 multiset<char>set;
	 
	 int i=0,j=0;
	 int n;
	 cin>>n;
	  int k;
	  cin>>k;
	  while(j<n)
	   {
	   	 set.insert(s[j]);
	   	 while(*set.rbegin()-*set.begin()>k)
	   	  {
	   	  	set.erase(set.find(s[i]));
	   	  	i++;
	   	  }
	   	  current_length=(j-i+1);
	   	  max_length=max(max_length,current_length);
	   	  j++;
	   }
	
	 cout<<max_length;
	
	return 0;
}