#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)

int main() {
    int64_t N, M, V, P;
    cin >> N >> M >> V >> P;
    vector<int64_t> A(N);
    for(auto &e : A) cin >> e;
    sort(A.begin(), A.end());
    rep(i, N) A[i] += M;
    vector<int64_t> cum(N + 1);
    rep(i, N) cum[i + 1] = cum[i] + A[i];
    int y = N - P;
    auto OK = [&](int x) -> bool {
        if(A[x] + M < A[y]) return false;
        int64_t S = cum[y + 1] - cum[x + 1];
        int64_t D = A[x] * (y - x);
        return S - D <= M * (N - V);
    };
    int l = -1, r = y;
    while(r - l > 1) {
        int mid = (l + r) / 2;
        OK(mid) ? r = mid : l = mid;
    }
    cout << N - r << '\n';
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
int n,m,a[N],b[N],match[N];
char s[N],t[N];
int main()
{
	scanf("%d%s%s",&n,s+1,t+1);
	if (!strcmp(s+1,t+1)) return puts("0"),0;
	for (int p=n,q=n;p;p--){
		while (t[p]==t[p-1]) p--;
		while (q&&(q>p||s[q]!=t[p])) q--;
		if (!q) return puts("-1"),0;
		match[p]=q;
	}
	for (int i=1;i<=n;i++)
		if (match[i]) m++,a[m]=match[i],b[m]=i;
	a[m+1]=b[m+1]=n+1;
	int ans=0,Max=0;
	for (int i=1;i<=m;i++)
		for (int j=a[i];j<a[i+1]-1;j++)
			if (s[j]!=s[j+1]) ans=1;
	for (int i=1;i<=m;i++){
		int l=0,r=m+1-i;
		while (l<r){
			int mid=(l+r)>>1;
			if (a[i+mid]-mid>=b[i]) r=mid;else l=mid+1;
		}
		Max=max(Max,l);
	}
	printf("%d\n",ans+Max);
	return 0;
}