1062
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int n, k;
bool alphabet[26] = {false};
vector<string> v;
int answer = 0;
int getWordCnt() {
int cnt = 0;
for(int i=0;i<v.size();i++) {
string str = v[i];
cnt++;
for(int j=4;j<str.length()-4;j++) {
if(!alphabet[str[j]-'0'-49]) {
cnt--;
break;
}
}
}
return cnt;
}
void dfs(int idx, int cnt) {
if(cnt==k) {
answer = max(answer,getWordCnt());
return;
}
for(int i=idx;i<26;i++) {
if(!alphabet[i]) {
alphabet[i] = true;
dfs(i+1, cnt+1);
alphabet[i] = false;
}
}
}
int main() {
alphabet['a'-'0'-49] = true;
alphabet['n'-'0'-49] = true;
alphabet['t'-'0'-49] = true;
alphabet['i'-'0'-49] = true;
alphabet['c'-'0'-49] = true;
cin>>n>>k;
for(int i=0;i<n;i++) {
string s;
cin>>s;
v.push_back(s);
}
if(k < 5) {
cout<<0;
return 0;
}
dfs(0,5);
cout<<answer;
}