#include <bits/stdc++.h>
using namespace std;
char s1[1000001], s2[1000001];
int a[100001], p[100001], length[1000001];
int n, m, len, num = 0;
void pd() {
  int u = 0;
  for (int i = 1; i <= num; ++i) {
    int k = 0;
    for (int j = 0; j < len; ++j)
      if (s1[j] != s2[p[i] + j]) ++k;
    if (k == 0) {
      ++a[i];
      u++;
    }
  }
  if (u == 0) {
    ++num;
    p[num] = p[num - 1] + length[num - 1];
    length[num] = len;
    a[num] = 1;
    for (int j = 0; j < len; ++j) {
      s2[p[num] + j] = s1[j];
    }
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    scanf("%s", &s1);
    len = strlen(s1);
    if (num == 0) {
      ++num;
      a[num] = 1;
      p[num] = 0;
      length[num] = len;
      for (int j = 0; j < len; ++j) s2[j] = s1[j];
    } else
      pd();
  }
  cin >> m;
  for (int o = 1; o <= m; ++o) {
    scanf("%s", &s1);
    len = strlen(s1);
    for (int i = 1; i <= num; ++i) {
      int k = 0;
      for (int j = 0; j < len; ++j) {
        if (s2[p[i] + j] != s1[j]) ++k;
      }
      if (k == 0) {
        a[i]--;
        break;
      }
    }
  }
  int max = -111111111;
  for (int i = 1; i <= num; ++i) {
    if (a[i] > max) max = a[i];
  }
  if (max < 0)
    cout << 0 << endl;
  else
    cout << max << endl;
}
