#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;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwojaW5jbHVkZSA8Yml0cy9zdGRjKysuaD4KCgppbnQgbWFpbigpIHsKCS8vIHlvdXIgY29kZSBnb2VzIGhlcmUKCQoJIHN0cmluZyBzOwoJIGNpbj4+czsKCSBpbnQgY3VycmVudF9sZW5ndGg9MCxtYXhfbGVuZ3RoPUlOVF9NSU47CgkgCgkgbXVsdGlzZXQ8Y2hhcj5zZXQ7CgkgCgkgaW50IGk9MCxqPTA7CgkgaW50IG47CgkgY2luPj5uOwoJICBpbnQgazsKCSAgY2luPj5rOwoJICB3aGlsZShqPG4pCgkgICB7CgkgICAJIHNldC5pbnNlcnQoc1tqXSk7CgkgICAJIHdoaWxlKCpzZXQucmJlZ2luKCktKnNldC5iZWdpbigpPmspCgkgICAJICB7CgkgICAJICAJc2V0LmVyYXNlKHNldC5maW5kKHNbaV0pKTsKCSAgIAkgIAlpKys7CgkgICAJICB9CgkgICAJICBjdXJyZW50X2xlbmd0aD0oai1pKzEpOwoJICAgCSAgbWF4X2xlbmd0aD1tYXgobWF4X2xlbmd0aCxjdXJyZW50X2xlbmd0aCk7CgkgICAJICBqKys7CgkgICB9CgkKCSBjb3V0PDxtYXhfbGVuZ3RoOwoJCglyZXR1cm4gMDsKfQ==