#include<cstdio>
#include<cctype>
#include<queue>
#include<cstring>
#include<algorithm>
#define rep(i,s,t) for(int i=s;i<=t;i++)
#define dwn(i,s,t) for(int i=s;i>=t;i--)
#define ren for(int i=first[x];i;i=next[i])
using namespace std;
inline int read() {
int x=0,f=1;char c=getchar();
for(;!isdigit(c);c=getchar()) if(c==‘-‘) f=-1;
for(;isdigit(c);c=getchar()) x=x*10+c-‘0‘;
return x*f;
}
typedef long long ll;
const int maxn=500010;
int n,s,S[maxn],Q[maxn],ans=-1;
int f[maxn],g[maxn],A[maxn],last[55];
char str[maxn];
int idx(char c) {return (c>=‘a‘&&c<=‘z‘)?c-‘a‘:c-‘A‘+26;}
ll solve(int x) {
rep(i,0,x-1) {
for(int j=i;j<n;j+=x) f[j]=last[A[j]],last[A[j]]=j;
for(int j=i;j<n;j+=x) last[A[j]]=-1;
}
int l=1,r=0;
rep(i,0,n-1) {
while(l<=r&&f[Q[r]]<f[i]) r--;Q[++r]=i;
while(Q[l]<=i-x) l++;
if(i>=x-1) g[i-x+1]=f[Q[l]];
}
rep(i,0,x-1) {
l=i;
for(int j=i;j+x-1<n;j+=x) {
while(l<=g[j]) l+=x;
if(j-l>=(s-1)*x) ans=max(ans,S[j+x]-S[l]);
}
}
}
int main() {
int l,r;
memset(last,-1,sizeof(last));
n=read();l=read();r=read();s=read();
rep(i,1,n) for(int j=i;j<=n;j+=i) S[j]++;
rep(i,2,n) S[i]+=S[i-1];
scanf("%s",str);
rep(i,0,n-1) A[i]=idx(str[i]);
rep(i,l,r) solve(i);
printf("%d\n",ans);
return 0;
}