#include<bits/stdc++.h>
using namespace std;
int K, N, M;
vector<string> words;
int maxCnt=0;
void backtrack(int i, vector<int> &lines, int cnt, const vector<string> &w){
if(i == w.size()){
if(cnt > maxCnt) maxCnt = cnt;
return;
}
if(cnt + (w.size()-i) <= maxCnt) return;
for(int j=0; j<N; j++){
if(lines[j]==0){
lines[j] = w[i].size();
backtrack(i+1, lines, cnt+1, w);
lines[j] = 0;
break;
}
else{
if(lines[j] + 1 + w[i].size() <= M){
lines[j] += 1 + w[i].size();
backtrack(i+1, lines, cnt+1, w);
lines[j] -= 1 + w[i].size();
}
}
}
backtrack(i+1, lines, cnt, w);
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cin>>K;
words.resize(K);
for(auto &s: words) cin>>s;
cin>>N>>M;
vector<string> valid;
for(auto &s: words) if((int)s.size() <= M) valid.push_back(s);
sort(valid.begin(), valid.end(), [&](const string &a, const string &b)->bool{
if(a.size() != b.size()) return a.size() > b.size();
return a < b;
});
vector<int> lines(N, 0);
backtrack(0, lines, 0, valid);
cout<<maxCnt;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBLLCBOLCBNOwp2ZWN0b3I8c3RyaW5nPiB3b3JkczsKaW50IG1heENudD0wOwoKdm9pZCBiYWNrdHJhY2soaW50IGksIHZlY3RvcjxpbnQ+ICZsaW5lcywgaW50IGNudCwgY29uc3QgdmVjdG9yPHN0cmluZz4gJncpewogICAgaWYoaSA9PSB3LnNpemUoKSl7CiAgICAgICAgaWYoY250ID4gbWF4Q250KSBtYXhDbnQgPSBjbnQ7CiAgICAgICAgcmV0dXJuOwogICAgfQogICAgaWYoY250ICsgKHcuc2l6ZSgpLWkpIDw9IG1heENudCkgcmV0dXJuOwogICAgZm9yKGludCBqPTA7IGo8TjsgaisrKXsKICAgICAgICBpZihsaW5lc1tqXT09MCl7CiAgICAgICAgICAgIGxpbmVzW2pdID0gd1tpXS5zaXplKCk7CiAgICAgICAgICAgIGJhY2t0cmFjayhpKzEsIGxpbmVzLCBjbnQrMSwgdyk7CiAgICAgICAgICAgIGxpbmVzW2pdID0gMDsKICAgICAgICAgICAgCiAgICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICBlbHNlewogICAgICAgICAgICBpZihsaW5lc1tqXSArIDEgKyB3W2ldLnNpemUoKSA8PSBNKXsKICAgICAgICAgICAgICAgIGxpbmVzW2pdICs9IDEgKyB3W2ldLnNpemUoKTsKICAgICAgICAgICAgICAgIGJhY2t0cmFjayhpKzEsIGxpbmVzLCBjbnQrMSwgdyk7CiAgICAgICAgICAgICAgICBsaW5lc1tqXSAtPSAxICsgd1tpXS5zaXplKCk7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9CiAgICBiYWNrdHJhY2soaSsxLCBsaW5lcywgY250LCB3KTsKfQoKaW50IG1haW4oKXsKICAgIGlvczo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTsKICAgIGNpbi50aWUoMCk7CiAgICBjaW4+Pks7CiAgICB3b3Jkcy5yZXNpemUoSyk7CiAgICBmb3IoYXV0byAmczogd29yZHMpIGNpbj4+czsKICAgIGNpbj4+Tj4+TTsKICAgIHZlY3RvcjxzdHJpbmc+IHZhbGlkOwogICAgZm9yKGF1dG8gJnM6IHdvcmRzKSBpZigoaW50KXMuc2l6ZSgpIDw9IE0pIHZhbGlkLnB1c2hfYmFjayhzKTsKICAgIHNvcnQodmFsaWQuYmVnaW4oKSwgdmFsaWQuZW5kKCksIFsmXShjb25zdCBzdHJpbmcgJmEsIGNvbnN0IHN0cmluZyAmYiktPmJvb2x7CiAgICAgICAgaWYoYS5zaXplKCkgIT0gYi5zaXplKCkpIHJldHVybiBhLnNpemUoKSA+IGIuc2l6ZSgpOwogICAgICAgIHJldHVybiBhIDwgYjsKICAgIH0pOwogICAgdmVjdG9yPGludD4gbGluZXMoTiwgMCk7CiAgICBiYWNrdHJhY2soMCwgbGluZXMsIDAsIHZhbGlkKTsKICAgIGNvdXQ8PG1heENudDsKfQ==