#include<stdio.h> #include<string.h> #include<algorithm> #include<vector> #include<set> #include<map> #include<string> #include<iostream> using namespace std; #define x first #define y second string s[105], S; map<string, int> mymap; int answer, n; char car; int main (){ for(int i = 1; i <= 26; i++){ cin >> car; cin >> s[car - 'a']; } cin >> n; for(int i = 1; i <= n; i++){ string morse = ""; cin >> S; int lim = S.size(); for(int j = 0; j < lim; j++){ morse += s[S[j] - 'a']; } mymap[morse]++; answer = max(answer, mymap[morse]); } cout << answer << endl; return 0; }