#include #include #include #include using namespace std; int mx = -1; int main() { ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr); unordered_map morse; unordered_map abc; char a; int n; string s; string p; for(char i = 'a'; i<='z'; ++i) { cin >> a >> s; morse[a] = s; } cin >> n; while(n--) { cin >> s; p = ""; for (char c : s) p += morse[c]; if (abc.find(p) == abc.end()) abc[p] = 1; else abc[p]++; mx = max(mx, abc[p]); } cout << mx; return 0; }