#include #include #include #include #include #define LMAX 100005 using namespace std; //FILE* in = freopen("date.in", "r", stdin); //FILE* out = freopen("date.out", "w", stdout); map morseCode; multiset 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::iterator it = repr.begin(); it != repr.end(); it++) if (repr.count(*it) > max) max = repr.count(*it); printf("%d\n", max); return 0; }