#include <cstdio> #include <map> #include <string> #include <set> #include <cstring> #define LMAX 100005 using namespace std; //FILE* in = freopen("date.in", "r", stdin); //FILE* out = freopen("date.out", "w", stdout); map <char, string> morseCode; multiset<string> repr; char word[LMAX]; int main() { for (char c = 'a'; c <= 'z'; c++) { char code[5]; scanf("%c %s\n", &c, code); string str(code); morseCode.insert(make_pair(c, str)); } int n; scanf("%d", &n); for (int i = 1; i <= n; i++) { string str; scanf("%s", word); int lg = strlen(word); for (int j = 0; j < lg; j++) { str += morseCode[word[j]]; } repr.insert(str); } int max = 0; for (multiset<string>::iterator it = repr.begin(); it != repr.end(); it++) { int count = repr.count(*it); if (count > max) max = count; } printf("%d\n", max); return 0; }