#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M, P = 0;
  string temp1, temp2;
  cin >> N;
  vector<string> N_s(N);
  for (int i = 0; i < N; i++) {
    cin >> N_s.at(i);
  }
  cin >> M;
  vector<string> M_t(M);
  for (int i = 0; i < M; i++) {
    cin >> M_t.at(i);
  }
  for (int i = 0; i < N; i++) {
    temp1 = N_s.at(i);
    for (int j = 0; j < M; j++) {
      temp2 = M_t.at(j);
      if (temp1.size() == temp2.size()) {
        for (int k = 0; k < temp1.size(); k++) {
          if (temp1.at(k) == temp2.at(k)) {
            P++;
          }
        }
      }
    }
  }
  cout << P << endl;
}
