#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <list>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int main() {
  vector<int> vec;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> vec[i];

  int m, k, ans = 0;
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> k;
    if (*lower_bound(vec.begin(), vec.end(), k) == k)
      ans++;
  }
  cout << ans << endl;
}

#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <list>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++)
    cin >> vec[i];

  int m, k, ans = 0;
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> k;
    if (*lower_bound(vec.begin(), vec.end(), k) == k)
      ans++;
  }
  cout << ans << endl;
}


#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

int main() {
  int n;
  int s[100001];
  int t[50001];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  int q;
  cin >> q;
  int count = 0;
  for (int i = 0; i < q; i++) {
    cin >> t[i];
  }
  for (int i = 0; i < q; i++) {
    for (int j = 0; j < n; j++) {
      if (t[i] == s[j]) {
        count++;
        break;
      }
    }
  }
  cout << count << endl;
  return 0;
}

#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

int main() {
  int n;
  int s[100001];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  int q;
  cin >> q;
  int count = 0;
  for (int i = 0; i < q; i++) {
    int t;
    cin >> t;
    int left = 0, right = n;
    while (left < right) {
      int mid = (left + right) / 2;
      if (s[mid] == t) {
        count++;
        break;
      } else if (t < s[mid]) {
        right = mid;
      } else {
        left = mid + 1;
      }
    }
  }
  cout << count << endl;
  return 0;
}


#include <stdio.h>
int main() {
  int i, n, j, k, o, count = 0;
  int a[10001];
  scanf("%d", &n);
  for (i = 0; i < n; i++)
    scanf("%d", &a[i]);
  int left = 0, right = n - 1;
  int cur = n / 2;
  scanf("%d", &k);
  for (i = 0; i < k; i++) {
    scanf("%d", &o);
    left = 0, right = n - 1;
    while (1) {
      if (left == right - 1 || left == right) {
        if (a[left] == o || a[right] == o)
          count++;
        break;
      }
      if (o == a[cur] || o == a[cur + 1]) {
        count++;
        break;
      }
      if (o > a[cur]) {
        left = cur;
        cur = (left + right) / 2;
      }
      if (o < a[cur]) {
        right = cur;
        cur = (left + right) / 2;
      }
    }
  }
  printf("%d\\n", count);
}

#include <stdio.h>
int main() {
  int i, n, j, k, o, count = 0;
  int a[1000001];
  scanf("%d", &n);
  for (i = 0; i < n; i++)
    scanf("%d", &a[i]);
  int left = 0, right = n - 1;
  int cur = n / 2;
  scanf("%d", &k);
  for (i = 0; i < k; i++) {
    scanf("%d", &o);
    left = 0, right = n - 1;
    while (1) {
      if (left == right - 1 || left == right) {
        if (a[left] == o || a[right] == o)
          count++;
        break;
      }
      if (o == a[cur] || o == a[cur + 1]) {
        count++;
        break;
      }
      if (o > a[cur]) {
        left = cur;
        cur = (left + right) / 2;
      }
      if (o < a[cur]) {
        right = cur;
        cur = (left + right) / 2;
      }
    }
  }
  printf("%d\\n", count);
}


#include <stdio.h>

#define N 10000
int S[N], T[N], count = 0, n, q, i, j, minj, temp, left, right, mid;
int binarySearch(int);
int main() {

  scanf("%d", &n);
  i = 0;
  while (i < n) {
    scanf("%d", &S[i]);
    i++;
  }

  scanf("%d", &q);
  i = 0;
  while (i < q) {
    scanf("%d", &T[i]);
    if (binarySearch(T[i]) == 1) {
      count++;
    }
    i++;
  }
  printf("%d\\n", count);

  return 0;
}

int binarySearch(int key) {
  left = 0;
  right = n;
  while (left < right) {
    mid = (left + right) / 2;
    if (S[mid] == key) {
      return 1;
    } else if (key < S[mid]) {
      right = mid;
    } else {
      left = mid + 1;
    }
  }
  return 0;
}

#include <stdio.h>

#define N 100000
int S[N], T[N], count = 0, n, q, i, j, minj, temp, left, right, mid;
int binarySearch(int);
int main() {

  scanf("%d", &n);
  i = 0;
  while (i < n) {
    scanf("%d", &S[i]);
    i++;
  }

  scanf("%d", &q);
  i = 0;
  while (i < q) {
    scanf("%d", &T[i]);
    if (binarySearch(T[i]) == 1) {
      count++;
    }
    i++;
  }
  printf("%d\\n", count);

  return 0;
}

int binarySearch(int key) {
  left = 0;
  right = n;
  while (left < right) {
    mid = (left + right) / 2;
    if (S[mid] == key) {
      return 1;
    } else if (key < S[mid]) {
      right = mid;
    } else {
      left = mid + 1;
    }
  }
  return 0;
}


#include <cstdio>
#include <iostream>

using namespace std;
void bubblesort(int a[], int n) {

  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j < i; j++) {
      if (a[j] > a[j + 1])
        swap(a[j], a[j + 1]);
    }
  }
}
int main() {
  int n, q;
  int S[100000], T[100000];
  int c = 0; // カウント
  int i = 0, j = 0;

  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> S[i];

  cin >> q;
  for (int j = 0; j < q; j++)
    cin >> T[j];

  bubblesort(T, q);

  // cout<<"test"<<endl;
  /*cout<<"S"<<endl;
  for(int i=0;i<n;i++) cout<<S[i]<<" ";
  cout<<endl;
          cout<<"Q"<<endl;
  for(int i=0;i<q;i++) cout<<T[i]<<" ";
  cout<<endl;*/

  while (j < q) {
    if (S[i] == T[j]) {
      c++;
      i++;
      j++;
    }
    if (S[i] > T[j])
      j++;
    if (S[i] < T[j])
      i++;
  }

  cout << c << endl;

  return 0;
}

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;

void bubblesort(int a[], int n) {

  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j < i; j++) {
      if (a[j] > a[j + 1])
        swap(a[j], a[j + 1]);
    }
  }
}

/*--- int型オブジェクトの比較関数 ---*/
int int_cmp(const int *a, const int *b) {
  if (*a < *b)
    return (-1);
  else if (*a > *b)
    return (1);
  return (0);
}

int main() {
  int n, q;
  int S[100000], T[100000];
  int c = 0; // カウント
  int i = 0, j = 0;

  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> S[i];

  cin >> q;
  for (int j = 0; j < q; j++)
    cin >> T[j];

  // bubblesort(T,q);
  qsort(T, q, sizeof(int), (int (*)(const void *, const void *))int_cmp);
  // cout<<"test"<<endl;
  /*cout<<"S"<<endl;
  for(int i=0;i<n;i++) cout<<S[i]<<" ";
  cout<<endl;
          cout<<"Q"<<endl;
  for(int i=0;i<q;i++) cout<<T[i]<<" ";
  cout<<endl;*/

  while (j < q) {
    if (S[i] == T[j]) {
      c++;
      i++;
      j++;
    }
    if (S[i] > T[j])
      j++;
    if (S[i] < T[j])
      i++;
  }

  cout << c << endl;

  return 0;
}


#include <iostream>

int binarySearch(int s[], int n, int key) {

  int head = 0;
  int tail = n - 1;

  int center;

  while (head != tail) {
    center = (head + tail) / 2;
    if (s[center] == key) {
      return center;
    } else if (s[center] < key) {
      head = center + 1;
    } else {
      tail = center - 1;
    }
  }

  if (s[head] == key) {
    return head;
  }

  return -1;
}

int main() {

  int n, q;
  int cnt = 0;

  std::cin >> n;

  int s[n];

  for (int i = 0; i < n; i++) {
    std::cin >> s[i];
  }

  std::cin >> q;

  int key;

  for (int i = 0; i < q; i++) {
    std::cin >> key;

    if (binarySearch(s, n, key) >= 0) {
      cnt++;
    }
  }

  std::cout << cnt << "\\n";
}

#include <iostream>

int binarySearch(int s[], int n, int key) {

  int head = 0;
  int tail = n - 1;

  int center;

  while (head != tail) {
    center = (head + tail) / 2;
    if (s[center] == key) {
      return center;
    } else if (s[center] < key) {
      head = center + 1;
    } else {
      tail = center;
    }
  }

  if (s[head] == key) {
    return head;
  }

  return -1;
}

int main() {

  int n, q;
  int cnt = 0;

  std::cin >> n;

  int s[n];

  for (int i = 0; i < n; i++) {
    std::cin >> s[i];
  }

  std::cin >> q;

  int key;

  for (int i = 0; i < q; i++) {
    std::cin >> key;

    if (binarySearch(s, n, key) >= 0) {
      cnt++;
    }
  }

  std::cout << cnt << "\\n";
}


#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <iostream>
using namespace std;
struct Node {
  int left_child, right_child;
  int sui, val;
  int fa;
} num[100010];
int n, len;
int sav[100010], zong;
void left_ch(int t) {
  int f = num[t].fa;
  num[f].right_child = num[t].left_child;
  num[num[t].left_child].fa = f;
  num[t].left_child = f;
  num[t].fa = num[f].fa;
  num[f].fa = t;
}

void right_ch(int t) {
  int f = num[t].fa;
  num[f].left_child = num[t].right_child;
  num[num[t].right_child].fa = f;
  num[t].right_child = f;
  num[t].fa = num[f].fa;
  num[f].fa = t;
}

int find_min() {
  int wz = 0;
  while (num[wz].left_child != -1) {
    wz = num[wz].left_child;
  }
  return num[wz].val;
}

int find_max() {
  int wz = 0;
  while (num[wz].right_child != -1) {
    wz = num[wz].right_child;
  }
  return num[wz].val;
}

int find_flag(int w) {
  int wz = 0;
  while (1) {
    if (num[wz].val > w) {
      if (num[wz].left_child == -1)
        break;
      wz = num[wz].left_child;
    } else if (num[wz].val < w) {
      if (num[wz].right_child == -1)
        break;
      wz = num[wz].right_child;
    } else if (num[wz].val == w)
      return wz;
  }
  return -1;
}

void insert(int w) {
  int o = rand() * rand(), wz = 0;
  int pla = len;
  if (zong != 0)
    pla = sav[--zong];
  else
    len++;
  num[pla].sui = o, num[pla].val = w, num[pla].left_child = -1,
  num[pla].right_child = -1;
  if (len == 0) {
    len = 1;
    return;
  }
  while (1) {
    if (num[wz].val > w) {
      if (num[wz].left_child == -1) {
        num[wz].left_child = len;
        break;
      }
      wz = num[wz].left_child;
    } else {
      if (num[wz].right_child == -1) {
        num[wz].right_child = len;
        break;
      }
      wz = num[wz].right_child;
    }
  }
  num[pla].fa = wz;
  while (1) {

    if (num[wz].right_child != -1 &&
        num[num[wz].right_child].sui < num[wz].sui) {
      left_ch(num[wz].right_child);
      wz = num[num[wz].fa].fa;
    } else if (num[wz].left_child != -1 &&
               num[num[wz].left_child].sui < num[wz].sui) {
      left_ch(num[wz].left_child);
      wz = num[num[wz].fa].fa;
    } else
      break;
  }
}

void delet(int w) {
  int wz = find_flag(w);
  while (num[wz].left_child != -1 || num[wz].right_child != -1) {
    if (num[wz].left_child == -1)
      right_ch(num[wz].right_child);
    else if (num[wz].right_child == -1)
      left_ch(num[wz].left_child);
    else {
      if (num[num[wz].left_child].sui < num[num[wz].right_child].sui)
        left_ch(num[wz].left_child);
      else
        right_ch(num[wz].right_child);
    }
  }
  if (num[num[wz].fa].left_child == wz)
    num[num[wz].fa].left_child = -1;
  else
    num[num[wz].fa].right_child = -1;
  sav[zong++] = wz;
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int www;
    cin >> www;
    insert(www);
  }
  cin >> n;
  int tot = 0;
  for (int i = 0; i < n; i++) {
    int www;
    cin >> www;
    if (find_flag(www) != -1)
      tot++;
  }
  cout << tot << "\\n";
  return 0;
}

#include <algorithm>
#include <cstring>
#include <iostream>
using namespace std;
#define MAXN 100000 + 2
int S[MAXN], Q[MAXN];
int n, m;
int gg = 0;
void input() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> S[i];
  }
  cin >> m;
  for (int i = 0; i < m; ++i) {
    cin >> Q[i];
  }
}
bool pd(int x) {
  int l = 0, r = n - 1;
  while (r > l) {
    int mid = (r + l) / 2;
    if (S[mid] == x)
      return true;
    if (S[mid] > x)
      r = mid;
    else
      l = mid + 1;
  }
  if (S[r] != x && S[l] != x)
    return false;
  else
    return true;
}
void output() { cout << gg << endl; }
int main() {
  input();
  for (int i = 0; i < m; ++i) {
    if (pd(Q[i]))
      gg++;
  }
  output();
  return 0;
}


#include <algorithm>
#include <iostream>

using namespace std;

bool myBinarySearch(int S[], int begin, int end, int target) {
  if (begin > end) {
    return false;
  }
  int mid = (begin + end) / 2;
  if (S[mid] > target) {
    return myBinarySearch(S, begin, mid - 1, target);
  } else if (S[mid] < target) {
    return myBinarySearch(S, mid + 1, end, target);
  } else {
    return true;
  }
}

int main(void) {
  int S[10000];
  int T[500];
  int n, m;

  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> S[i];
  }
  sort(S, S + m);

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> T[i];
  }
  sort(T, T + n);

  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (myBinarySearch(S, 0, m, T[i])) {
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}

#include <algorithm>
#include <iostream>

using namespace std;

bool myBinarySearch(int S[], int begin, int end, int target) {
  if (begin > end) {
    return false;
  }
  int mid = (begin + end) / 2;
  if (S[mid] > target) {
    return myBinarySearch(S, begin, mid - 1, target);
  } else if (S[mid] < target) {
    return myBinarySearch(S, mid + 1, end, target);
  } else {
    return true;
  }
}

int main(void) {
  int S[100000];
  int T[50000];
  int n, m;

  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> S[i];
  }
  sort(S, S + m);

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> T[i];
  }
  sort(T, T + n);

  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (myBinarySearch(S, 0, m, T[i])) {
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)
#define RFOR(i, a, b) for (int i = (a)-1; i >= (b); i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int s[10003], t[5003];
  int n, q;
  cin >> n;
  REP(i, n) cin >> s[i];
  cin >> q;
  REP(i, q) cin >> t[i];
  int ct = 0;
  REP(i, q) {
    int l = 0;
    int r = n;
    while (abs(r - l) > 1) {
      int mid = (r + l) / 2;
      if (t[i] < s[mid])
        r = mid;
      else
        l = mid;
    }
    if (s[(r + l) / 2] == t[i])
      ct++;
  }
  cout << ct << endl;
  return 0;
}

#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)
#define RFOR(i, a, b) for (int i = (a)-1; i >= (b); i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int s[100003], t[50003];
  int n, q;
  cin >> n;
  REP(i, n) cin >> s[i];
  cin >> q;
  REP(i, q) cin >> t[i];
  int ct = 0;
  REP(i, q) {
    int l = 0;
    int r = n;
    while (abs(r - l) > 1) {
      int mid = (r + l) / 2;
      if (t[i] < s[mid])
        r = mid;
      else
        l = mid;
    }
    if (s[(r + l) / 2] == t[i])
      ct++;
  }
  cout << ct << endl;
  return 0;
}


#include <iostream>
using namespace std;

int binarySearch(int n, int s[], int t) {
  int i = 0;
  int j = n - 1;
  while (i <= j) {
    int mid = i + (j - i) / 2;
    int guess = s[mid];
    if (guess == t) {
      return 1;
    }
    if (guess < t) {
      i = mid + 1;
    } else {
      j = mid - 1;
    }
  }
  return 0;
}

int main() {
  int n, q, s[10001], t, ans = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> t;
    ans += binarySearch(n, s, t);
  }
  cout << ans << endl;
  return 0;
}

#include <iostream>
using namespace std;

int binarySearch(int n, int s[], int t) {
  int i = 0;
  int j = n - 1;
  while (i <= j) {
    int mid = i + (j - i) / 2;
    int guess = s[mid];
    if (guess == t) {
      return 1;
    }
    if (guess < t) {
      i = mid + 1;
    } else {
      j = mid - 1;
    }
  }
  return 0;
}

int main() {
  int n, q, s[100000], t, ans = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> t;
    ans += binarySearch(n, s, t);
  }
  cout << ans << endl;
  return 0;
}


#include <iostream>
using namespace std;
int n, a[10000000];
inline int search(int key) {
  int l = 0;
  int r = n;
  while (r > l) {
    int mid = (l + r) / 2;
    if (a[mid] = key)
      return 1;
    else if (a[mid] < key)
      l = mid + 1;
    else if (a[mid] > key)
      r = mid;
  }
  return 0;
}
int main() {
  const int num = 10001;
  int q, key, sum = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> key;
    if (search(key))
      sum++;
  }
  cout << sum << endl;
  return 0;
}

#include <iostream>
using namespace std;
int n, a[10000000];
inline int search(int key) {
  int l = 0;
  int r = n;

  while (r > l) {
    int mid = (l + r) / 2;
    if (a[mid] == key)
      return 1;
    else if (a[mid] < key)
      l = mid + 1;
    else if (a[mid] > key)
      r = mid;
  }
  return 0;
}
int main() {
  const int num = 10001;
  int q, key, sum = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> key;
    if (search(key))
      sum++;
  }
  cout << sum << endl;
  return 0;
}


#include <stdio.h>

int A[1000000], n;

int binarySearch(int key) {
  int left = 0;
  int right = n;
  int mid;
  while (left < right) {
    mid = (left + right) / 2;
    if (A[mid] == key)
      return 1;
    if (key < A[mid])
      right = mid - 1;
    else if (key > A[mid])
      left = mid;
  }
  return 0;
}

int main() {
  int i, q, key, sum = 0;

  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }

  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d", &key);
    if (binarySearch(key))
      sum++;
  }
  printf("%d\\n", sum);

  return 0;
}

#include <stdio.h>

int A[1000000], n;

int binarySearch(int key) {
  int left = 0;
  int right = n;
  int mid;
  while (left <= right) {
    mid = (left + right) / 2;
    if (A[mid] == key)
      return 1;
    if (key < A[mid])
      right = mid - 1;
    else if (key > A[mid])
      left = mid + 1;
  }
  return 0;
}

int main() {
  int i, q, key, sum = 0;

  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }

  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d", &key);
    if (binarySearch(key))
      sum++;
  }
  printf("%d\\n", sum);

  return 0;
}


#include <stdio.h>

int A[1000000], n;

int binarySearch(int key) {
  int left = 0;
  int right = n;
  int mid;
  while (left < right) {
    mid = (left + right) / 2;
    if (A[mid] == key)
      return 1;
    if (key < A[mid])
      right = mid;
    else if (key > A[mid])
      left = mid + 1;
  }
  return 0;
}

int main() {
  int i, q, key, sum = 0;

  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }

  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d", &key);
    if (binarySearch(key))
      sum++;
  }
  printf("%d\\n", sum);

  return 0;
}


#include <stdio.h>

int A[1000000], n;

int binarySearch(int key) {
  int left = 0;
  int right = n;
  int mid;
  while (left < right) {
    mid = (right - left > 1) / 2;
    if (A[mid] == key)
      return 1;
    if (key < A[mid])
      right = mid;
    else if (key > A[mid])
      left = mid;
  }
  return 0;
}

int main() {
  int i, q, key, sum = 0;

  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }

  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d", &key);
    if (binarySearch(key))
      sum++;
  }
  printf("%d\\n", sum);

  return 0;
}

#include <stdio.h>

int A[1000000], n;

int binarySearch(int key) {
  int left = 0;
  int right = n - 1;
  int mid;
  while (left <= right) {
    mid = (left + right) / 2;
    if (A[mid] == key)
      return 1;
    if (key < A[mid])
      right = mid - 1;
    else if (key > A[mid])
      left = mid + 1;
  }
  return 0;
}

int main() {
  int i, q, key, sum = 0;

  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }

  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d", &key);
    if (binarySearch(key))
      sum++;
  }
  printf("%d\\n", sum);

  return 0;
}


#include <algorithm>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

const int INF = 1 << 29;
typedef pair<int, int> P;

int main(void) {
  while (true) {
    int n, q;
    cin >> n;
    vector<int> s(n);
    for (int i = 0; i < n; i++) {
      cin >> s[i];
    }
    int ans = 0;
    cin >> q;
    for (int i = 0; i < q; i++) {
      int t;
      cin >> t;
      vector<int>::iterator it = lower_bound(s.begin(), s.end(), t);
      if (it != s.end() && *it == t)
        ans++;
    }
    cout << ans << endl;
  }
  return 0;
}

#include <algorithm>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

const int INF = 1 << 29;
typedef pair<int, int> P;

int main(void) {
  int n, q;
  cin >> n;
  vector<int> s(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  int ans = 0;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int t;
    cin >> t;
    vector<int>::iterator it = lower_bound(s.begin(), s.end(), t);
    if (it != s.end() && *it == t)
      ans++;
  }
  cout << ans << endl;
  return 0;
}


#include <iostream>
#include <vector>

using namespace std;

bool search(vector<int> &S, int s, int b, int e) {
  int m = (e + b) / 2;
  int _s = S[m];
  if (s == _s)
    return true;
  if (b == e)
    return false;
  if (_s > s)
    return search(S, s, b, m - 1);
  if (_s < s)
    return search(S, s, m + 1, e);
}

int main() {
  int n;
  cin >> n;
  vector<int> S(n);
  for (auto &s : S)
    cin >> s;
  int q;
  cin >> q;
  int C = 0;
  while (q--) {
    int t;
    cin >> t;
    if (search(S, t, 0, n - 1))
      C++;
  }
  cout << C << endl;
}

#include <iostream>
#include <vector>

using namespace std;

bool search(vector<int> &S, int s, int b, int e) {
  int m = (e + b) / 2;
  if (m < b)
    return false;
  int _s = S[m];
  if (s == _s)
    return true;
  if (b == e)
    return false;
  if (_s > s)
    return search(S, s, b, m - 1);
  if (_s < s)
    return search(S, s, m + 1, e);
}

int main() {
  int n;
  cin >> n;
  vector<int> S(n);
  for (auto &s : S)
    cin >> s;
  int q;
  cin >> q;
  int C = 0;
  while (q--) {
    int t;
    cin >> t;
    if (search(S, t, 0, n - 1))
      C++;
  }
  cout << C << endl;
}


#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EACH(i, c)                                                             \\
  for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                                               \\
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"                       \\
       << " " << __FILE__ << endl;
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

using namespace std;

bool binary_search(vector<int> v, int kay) {
  int left = 0;
  int right = SZ(v);
  int mid;
  while (left < right) {
    mid = (left + right) / 2;
    if (v[mid] == kay)
      return true;
    else if (kay < v[mid])
      right = mid;
    else
      left = mid;
  }
  return false;
}

signed main() {
  // cin.tie(0);
  // ios::sync_with_stdio(false);

  int n;
  cin >> n;

  vector<int> v;
  int t;
  REP(_, n) {
    cin >> t;
    v.PB(t);
  }

  cin >> n;
  int count = 0;
  REP(_, n) {
    cin >> t;
    if (binary_search(v, t))
      count++;
  }

  cout << count << endl;
}

#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EACH(i, c)                                                             \\
  for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                                               \\
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"                       \\
       << " " << __FILE__ << endl;
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

using namespace std;

bool binary_search(vector<int> v, int kay) {
  int left = 0;
  int right = SZ(v);
  int mid;
  while (left < right) {
    mid = (left + right) / 2;
    if (v[mid] == kay)
      return true;
    else if (kay < v[mid])
      right = mid;
    else
      left = mid + 1;
  }
  return false;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;

  vector<int> v;
  int t;
  REP(_, n) {
    cin >> t;
    v.PB(t);
  }

  cin >> n;
  int count = 0;
  REP(_, n) {
    cin >> t;
    if (binary_search(v, t))
      count++;
  }

  cout << count << endl;
}


#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EACH(i, c)                                                             \\
  for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define CLR(a) memset((a), 0, sizeof(a))
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                                               \\
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"                       \\
       << " " << __FILE__ << endl;
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

using namespace std;

const int dy[] = {0, 0, 1, -1};
const int dx[] = {1, -1, 0, 0};
const double EPS = 1e-10;
const double PI = acos(-1.0);

bool is_exist(vector<int> vec, int n, int head, int hip) {
  int mid = (head + hip) / 2;
  if (vec[mid] == n)
    return true;
  else if (head == hip)
    return false;

  if (vec[mid] < n)
    return is_exist(vec, n, mid, hip);
  if (vec[mid] > n)
    return is_exist(vec, n, head, mid);

  return false;
}

signed main() {
  // cin.tie(0);
  // ios::sync_with_stdio(false);

  int n;
  cin >> n;
  vector<int> s;
  REP(_, n) {
    int num;
    cin >> num;
    s.PB(num);
  }

  int q;
  cin >> q;
  int res = 0;
  REP(_, q) {
    int num;
    cin >> num;

    if (is_exist(s, num, 0, s.size()))
      res++;
  }

  cout << res << endl;
}

#include <algorithm>
#include <cfloat>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int main() {
  int N;
  cin >> N;
  int S[N];
  for (int i = 0; i < N; i++)
    cin >> S[i];

  int M;
  cin >> M;

  int Q[M];
  for (int i = 0; i < M; i++)
    cin >> Q[i];
  sort(Q, Q + M);

  int left = 0, right, m, count = 0;

  for (int i = 0; i < M; i++) {
    right = N - 1;
    m = (left + right) / 2;

    while (left <= right) {
      if (S[m] == Q[i]) {
        count++;
        left = m + 1;
        break;
      } else if (S[m] > Q[i]) {
        right = m - 1;
      } else { // S[m] < Q[i]
        left = m + 1;
      }
      m = (left + right) / 2;
    }
  }
  cout << count << endl;
}


#include <iostream>
#include <string>

using namespace std;

int main() {
  int n;
  std::cin >> n;
  int S[100001];
  for (int i = 0; i < n; i++) {
    std::cin >> S[i];
  }
  int q;
  std::cin >> q;
  int T[50000];
  for (int i = 0; i < q; i++) {
    std::cin >> T[i];
  }

  int count = 0;

  for (int i = 0; i < q; i++) {
    for (int j = 0; j < n; j++) {
      if (S[j] == T[i]) {
        count++;
        break;
      }
    }
  }
  std::cout << count << '\\n';
}

#include <iostream>
#include <string>

using namespace std;

int main() {
  int n;
  std::cin >> n;
  int S[100001];
  for (int i = 0; i < n; i++) {
    std::cin >> S[i];
  }
  int q;
  std::cin >> q;
  int T[50000];
  for (int i = 0; i < q; i++) {
    std::cin >> T[i];
  }

  int count = 0;

  for (int i = 0; i < q; i++) {
    int left = 0;
    int right = n;
    while (left < right) {
      int mid = (left + right) / 2;
      if (S[mid] == T[i]) {
        count++;
        break;
      } else if (T[i] < S[mid]) {
        right = mid;
      } else if (T[i] > S[mid]) {
        left = mid + 1;
      }
    }
  }
  std::cout << count << '\\n';
}


#include <cassert>
#include <fstream>
#include <iostream>
#include <map>
#include <stack>
#include <string.h>
#include <vector>

// TODO テンプレート化したい
// std::vector<int>::iterator binarySearch(std::vector<int> sorted_array, int
// value)
// {
//     int left  = 0;
//     int right = sorted_array.size();

//     while (left < right - 1) {
//         int current = (left + right) / 2;
//         if(value == sorted_array.at(current)){
//             return sorted_array.begin() + current;
//         }else if(value < sorted_array.at(current)){
//             right = current;
//         }else{
//             left = current;
//         }
//     }

//     return sorted_array.end();
// }

int binarySearch(std::vector<int> sorted_array, int value) {
  int left = 0;
  int right = sorted_array.size();

  while (left < right) {
    int current = (left + right) / 2;
    if (value == sorted_array.at(current)) {
      return current;
    } else if (value < sorted_array.at(current)) {
      right = current;
    } else {
      left = current;
      if (current + 1 == right)
        break;
    }
  }

  return sorted_array.size();
}

std::vector<int> createVectorFronCin(int cnt) {
  std::vector<int> ret;
  ret.reserve(cnt);

  int cur = 0;
  for (int i = 0; i < cnt; ++i) {
    std::cin >> cur;
    ret.push_back(cur);
  }

  return ret;
}

int main() {
  std::ifstream ifs("input/alds1_04_b_01.txt");
  if (!ifs)
    assert(false);
  std::cin.rdbuf(ifs.rdbuf());

  int n = 0;
  int q = 0;

  std::cin >> n;
  std::vector<int> sorted_array = createVectorFronCin(n);

  std::cin >> q;
  std::vector<int> values = createVectorFronCin(q);

  int counter = 0;
  for (std::vector<int>::iterator it = values.begin(); it < values.end();
       ++it) {
    int pos = binarySearch(sorted_array, *it);
    if (pos < sorted_array.size())
      counter++;

    // std::vector<int>::iterator pos = binarySearch(sorted_array, *it);
    // if (pos != sorted_array.end())
    //     counter++;

    // if (binarySearch(sorted_array, *it) != sorted_array.end())
    //     counter++;
  }

  std::cout << counter << std::endl;
}

#include <cassert>
#include <fstream>
#include <iostream>
#include <map>
#include <stack>
#include <string.h>
#include <vector>

// TODO テンプレート化したい
// std::vector<int>::iterator binarySearch(std::vector<int> sorted_array, int
// value)
// {
//     int left  = 0;
//     int right = sorted_array.size();

//     while (left < right - 1) {
//         int current = (left + right) / 2;
//         if(value == sorted_array.at(current)){
//             return sorted_array.begin() + current;
//         }else if(value < sorted_array.at(current)){
//             right = current;
//         }else{
//             left = current;
//         }
//     }

//     return sorted_array.end();
// }

int binarySearch(std::vector<int> sorted_array, int value) {
  int left = 0;
  int right = sorted_array.size();

  while (left < right) {
    int current = (left + right) / 2;
    if (value == sorted_array.at(current)) {
      return current;
    } else if (value < sorted_array.at(current)) {
      right = current;
    } else {
      left = current;
      if (current + 1 == right)
        break;
    }
  }

  return sorted_array.size();
}

std::vector<int> createVectorFronCin(int cnt) {
  std::vector<int> ret;
  ret.reserve(cnt);

  int cur = 0;
  for (int i = 0; i < cnt; ++i) {
    std::cin >> cur;
    ret.push_back(cur);
  }

  return ret;
}

int main() {
  int n = 0;
  int q = 0;

  std::cin >> n;
  std::vector<int> sorted_array = createVectorFronCin(n);

  std::cin >> q;
  std::vector<int> values = createVectorFronCin(q);

  int counter = 0;
  for (std::vector<int>::iterator it = values.begin(); it < values.end();
       ++it) {
    int pos = binarySearch(sorted_array, *it);
    if (pos < sorted_array.size())
      counter++;

    // std::vector<int>::iterator pos = binarySearch(sorted_array, *it);
    // if (pos != sorted_array.end())
    //     counter++;

    // if (binarySearch(sorted_array, *it) != sorted_array.end())
    //     counter++;
  }

  std::cout << counter << std::endl;
}

6f4cb61d-06b0-48d4-85ba-58e1d35c3dc5.out: /home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02268/C++/s459023231.cpp:68: int main(): Assertion `false' failed.


#include <stdio.h>

int A[1000000], n;

int binarySearch(int key) {
  int left = 0;
  int right = n;
  int mid;
  while (left < right) {
    mid = (left + right) / 2;
    if (A[mid] == key)
      return 1;
    if (key < A[mid])
      right = mid;
    else if (key > A[mid])
      left = mid + 1;
  }
  return 0;
}

int main() {
  int i, q, key, sum = 0;

  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", A[i]);
  }

  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d", &key);
    if (binarySearch(key))
      sum++;
  }
  printf("%d\\n", sum);

  return 0;
}


#include <iostream>
using namespace std;
int main() {
  int n, s[100000], q, t[50000], i, j, l, r, m, count = 0;

  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> s[i];
  }
  cin >> q;
  for (i = 0; i < q; i++) {
    cin >> t[i];
  }

  // Binary Search

  for (i = 0; i < q; i++) {
    l = 0;
    r = n;
    while (l < r) {
      m = (l + r) / 2;
      if (s[m] > t[i]) {
        r = m;
      } else if (s[m] < t[i]) {
        l = m;
      } else {
        count++;
        break;
      }
    }
  }

  cout << count << endl;

  return 0;
}

#include <iostream>
using namespace std;
int main() {
  int n, s[100000], q, t[50000], i, j, l, r, m, count = 0;

  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> s[i];
  }
  cin >> q;
  for (i = 0; i < q; i++) {
    cin >> t[i];
  }

  // Binary Search

  for (i = 0; i < q; i++) {
    l = 0;
    r = n;
    while (l < r) {
      m = (l + r) / 2;
      if (s[m] > t[i]) {
        r = m;
      } else if (s[m] < t[i]) {
        l = m + 1;
      } else {
        count++;
        break;
      }
    }
  }

  cout << count << endl;

  return 0;
}


#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <stack>
#include <stdio.h>
#include <string>

int binarysearch(int a[], int n, int key) {
  int left = 0;
  int right = n;
  int mid;
  while (left < right) {
    mid = (left + right) / 2;
    if (key == a[mid])
      return 1;
    if (key > a[mid])
      left = mid + 1;
    else if (key < a[mid])
      right = mid;
  }
  return 0;
}
using namespace std;
int main() {
  int i, n, a[10001], q, key, sum = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    scanf("%d", &key);
    if (binarysearch(a, n, key))
      sum++;
  }
  printf("%d\\n", sum);
  return 0;
}

#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <stack>
#include <stdio.h>
#include <string>

int binarysearch(int a[], int n, int key) {
  int left = 0;
  int right = n;
  int mid;
  while (left < right) {
    mid = (left + right) / 2;
    if (key == a[mid])
      return 1;
    if (key > a[mid])
      left = mid + 1;
    else if (key < a[mid])
      right = mid;
  }
  return 0;
}
using namespace std;
int main() {
  int i, n, a[100001], q, key, sum = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    scanf("%d", &key);
    if (binarysearch(a, n, key))
      sum++;
  }
  printf("%d\\n", sum);
  return 0;
}


#include <stdio.h>

int search(int A[], int n, int key) {
  int i = 0;
  A[n] = key;
  while (A[i] != key)
    i++;
  return i != n;
}

int main() {
  int i, n, A[10000 + 1], q, key, sum = 0;

  scanf("%d", &n);
  for (i = 0; i < n; i++)
    scanf("%d", &A[i]);

  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    scanf("%d", &key);
    if (search(A, n, key))
      sum++;
  }
  printf("%d\\n", sum);

  return 0;
}

#include <iostream>
using namespace std;

int A[1000000], n;

int binarySearch(int key) {
  int left = 0;
  int right = n;
  int mid;

  while (left < right) {
    mid = (left + right) / 2;
    if (key == A[mid])
      return 1;
    if (key > A[mid])
      left = mid + 1;
    else if (key < A[mid])
      right = mid;
  }
  return 0;
}

int main() {
  int i, q, k, sum = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> k;
    if (binarySearch(k))
      sum++;
  }
  cout << sum << endl;

  return 0;
}


#include <stdio.h>

// Cにbooleanはないのでint(0 / 1)で判定する
int search(int A[], int n, int key) {
  int i = 0;
  A[n] = key; // 配列の末尾に番兵を用意
  while (A[i] != key)
    i++;
  return i != n; // i == n
                 // は番兵まで到達してしまった（存在しなかった）という意味になる
}

// 計算量はO(qn)
int main() {
  int i, n, A[10000 + 1], q, key, sum = 0;

  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }

  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    scanf("%d", &key);
    if (search(A, n, key))
      sum++;
  }

  printf("%d\\n", sum);

  return 0;
}

#include <stdio.h>

int A[1000000], n;

int binarySearch(int key) {
  int left = 0;
  int right = n;
  int mid;
  while (left < right) {
    mid = (left + right) / 2;
    if (key == A[mid])
      return 1;
    if (key > A[mid])
      left = mid + 1;
    else if (key < A[mid])
      right = mid;
  }
  return 0;
}

// 計算量はO(qn)
int main() {
  int i, q, key, sum = 0;

  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }

  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    scanf("%d", &key);
    if (binarySearch(key))
      sum++;
  }

  printf("%d\\n", sum);

  return 0;
}


#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef pair<int, int> lake;

int main(void) {
  int n, q;
  cin >> n;
  vector<int> s(n);
  for (int i = 0; i < n; i++)
    cin >> s[i];
  cin >> q;
  vector<int> t(q);
  for (int i = 0; i < q; i++)
    cin >> t[i];
  // sort(s.begin(), s.end());
  // sort(t.begin(), t.end());
  int count = 0;
  for (int i = 0; i < q; i++) {
    int left = 0;
    int right = n;
    while (left < right) {
      int mid = (left + right) / 2;
      if (s[mid] == t[i]) {
        count++;
        break;
      } else if (s[mid] < t[i]) {
        left = mid;
      } else {
        right = mid;
      }
    }
  }
  cout << count << endl;
  return 0;
}

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef pair<int, int> lake;

int main(void) {
  int n, q;
  cin >> n;
  vector<int> s(n);
  for (int i = 0; i < n; i++)
    cin >> s[i];
  cin >> q;
  vector<int> t(q);
  for (int i = 0; i < q; i++)
    cin >> t[i];
  // sort(s.begin(), s.end());
  // sort(t.begin(), t.end());
  int count = 0;
  for (int i = 0; i < q; i++) {
    int left = 0;
    int right = n;
    while (left < right) {
      int mid = (left + right) / 2;
      if (s[mid] == t[i]) {
        count++;
        break;
      } else if (s[mid] < t[i]) {
        left = mid + 1;
      } else {
        right = mid;
      }
    }
  }
  cout << count << endl;
  return 0;
}


#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;

bool search(int a[], int n, int t) {
  int left = 0, right = n;

  int mid = (left + right) / 2;
  while (left < right) {
    if (a[mid] = t) {
      return true;
    } else if (a[mid] < t) {
      left = mid + 1;
    } else {
      right = mid;
    }
  }
  return false;
}

int main() {
  int n1;
  cin >> n1;

  int s[n1];
  for (int i = 0; i < n1; i++) {
    scanf("%d", &s[i]);
  }

  int n2;
  cin >> n2;

  int t, ans = 0;
  for (int i = 0; i < n2; i++) {
    scanf("%d", &t);
    if (search(s, n1, t))
      ans++;
  }

  cout << ans << endl;

  return 0;
}

#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;

bool search(int a[], int n, int t) {
  int left = 0, right = n;

  while (left < right) {
    int mid = (left + right) / 2;
    if (a[mid] == t) {
      return true;
    } else if (a[mid] < t) {
      left = mid + 1;
    } else {
      right = mid;
    }
  }
  return false;
}

int main() {
  int n1;
  cin >> n1;

  int s[n1];
  for (int i = 0; i < n1; i++) {
    scanf("%d", &s[i]);
  }

  int n2;
  cin >> n2;

  int t, ans = 0;
  for (int i = 0; i < n2; i++) {
    scanf("%d", &t);
    if (search(s, n1, t))
      ans++;
  }

  cout << ans << endl;

  return 0;
}


#include <cstdio>
#include <iostream>
#define N 100000
#include <algorithm>
using namespace std;

int T[N + 1];
int BinarySearch(int k, int n) {
  int left = 0, right = n;
  while (left < right) {
    int mid = (left + right) / 2;
    if (T[mid] == k)
      return 1;
    else if (T[mid] < k)
      left = mid;
    else if (T[mid] > k)
      right = mid;
  }
  return 0;
}
int main() {
  int n, q, t, sum = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d", &T[i]);
  }
  sort(T, T + n);
  cin >> q;
  for (int i = 0; i < q; i++) {
    scanf("%d", &t);
    if (BinarySearch(t, n))
      sum++;
  }
  cout << sum << endl;
  return 0;
}

#include <cstdio>
#include <iostream>
#define N 100000
#include <algorithm>
using namespace std;

int T[N + 1];
int BinarySearch(int k, int n) {
  int mid, left = 0, right = n;
  while (left < right) {
    mid = (left + right) / 2;
    if (T[mid] == k)
      return 1;
    else if (T[mid] < k)
      left = mid + 1;
    else if (T[mid] > k)
      right = mid;
  }
  return 0;
}
int main() {
  int n, q, t, sum = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d", &T[i]);
  }
  sort(T, T + n);
  cin >> q;
  for (int i = 0; i < q; i++) {
    scanf("%d", &t);
    if (BinarySearch(t, n))
      sum++;
  }
  cout << sum << endl;
  return 0;
}


#include <iostream>
using namespace std;
int main() {
  int n, m, cnt = 0;
  int st, en, syo;
  int tmp, a;
  int hi[100000];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> hi[i];
    for (int j = 0; j < i; j++) {
      if (hi[j] > hi[i]) {
        tmp = hi[i];
        hi[i] = hi[j];
        hi[j] = tmp;
      }
    }
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    st = 0;
    en = n;
    cin >> a;
    while (st != en && st < en) {
      syo = st + ((en - st) / 2);
      if (a == hi[syo]) {
        cnt++;
        break;
      } else {
        if (hi[syo] > a)
          en = syo - 1;
        else
          st = syo + 1;
      }
    }
    if (st == en) {
      if (hi[st] == a)
        cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}

#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int n, m, cnt = 0;
  int st, en, syo;
  int tmp, a;
  int hi[100000];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> hi[i];
    /*
                    for(int j=0;j<i;j++)
                    {
                            if(hi[j]>hi[i])
                            {
                                    tmp=hi[i];
                                    hi[i]=hi[j];
                                    hi[j]=tmp;
                            }
                    }
    */
  }
  sort(hi, hi + n);
  cin >> m;
  for (int i = 0; i < m; i++) {
    st = 0;
    en = n;
    cin >> a;
    while (st != en && st < en) {
      syo = st + ((en - st) / 2);
      if (a == hi[syo]) {
        cnt++;
        break;
      } else {
        if (hi[syo] > a)
          en = syo - 1;
        else
          st = syo + 1;
      }
    }
    if (st == en) {
      if (hi[st] == a)
        cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

int n;
bool my_search(int key, vector<int> v) {
  int up = n;
  int down = 0;
  while (down < up) {
    int mid = (up + down) / 2;
    if (v[mid] > key) {
      up = mid;
    } else if (v[mid] == key) {
      return 1;
    } else {
      down = mid + 1;
    }
  }
  return 0;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++)
    cin >> v[i];
  sort(v.begin(), v.end());

  int q;
  cin >> q;
  int t;
  int cnt = 0;
  for (int i = 0; i < q; i++) {
    cin >> t;
    if (my_search(t, v)) {
      cnt++;
    }
    cerr << cnt << endl;
  }
  cout << cnt << endl;
  return 0;
}

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

int n;
bool my_search(int key, vector<int> v) {
  int up = n;
  int down = 0;
  while (down < up) {
    int mid = (up + down) / 2;
    if (v[mid] > key) {
      up = mid;
    } else if (v[mid] == key) {
      return true;
    } else {
      down = mid + 1;
    }
  }
  return false;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++)
    cin >> v[i];
  sort(v.begin(), v.end());

  int q;
  cin >> q;
  int t;
  int cnt = 0;
  for (int i = 0; i < q; i++) {
    cin >> t;
    if (my_search(t, v)) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <istream>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
//------------------------------------define------------------------//
#define PB push_buck
#define MP make_pair
//------------------------------------typedef-----------------------//
typedef long long LL;

using namespace std;

int a, b, c, d, e, f, g, h, i, j, k, l, n;
vector<int> s1;
vector<pair<int, int>> s2;
stack<int> s3;
queue<int> s4;
list<int> s5;

//--------------------------------------------------------------//
int binafySearch(int key) {
  int left = 0;
  int right = n;
  int midle;
  int A[1000000];
  while (left < right) {
    midle = (left + right) / 2;
    if (key == A[midle]) {
      return 1;
    } else if (key < A[midle]) {
      right = midle;
    } else if (key > A[midle]) {
      left = midle;
    }
  }
}

int main() {
  int sum = 0;
  int A[1000000];
  int q;
  int key;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> key;

    if (binafySearch(key)) {
      sum++;
    }
  }
  printf("%d", sum);
}

#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <istream>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
//------------------------------------define------------------------//

//------------------------------------typedef-----------------------//

using namespace std;

int n, A[1000000];
//--------------------------------------------------------------//
int binafySearch(int key) {
  int left = 0;
  int right = n;
  int midle;
  while (left < right) {
    midle = (left + right) / 2;
    if (key == A[midle]) {
      return 1;
    }
    if (key < A[midle]) {
      right = midle;
    } else if (key > A[midle]) {
      left = midle + 1;
    }
  }
  return 0;
}

int main() {
  int sum = 0;
  int q;
  int key;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> key;

    if (binafySearch(key)) {
      sum++;
    }
  }
  printf("%d\\n", sum);
  return 0;
}


#include <algorithm>
#include <iostream>
#define SIZE 10000
using namespace std;

bool compare(int a, int b) { return a < b; }

int main() {
  int q;
  int a[SIZE];

  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> a[i];
  }

  sort(a, a + q, compare);

  int t;
  cin >> t;
  int b[SIZE];
  for (int j = 0; j < t; j++) {
    cin >> b[j];
  }

  int n = 0;
  for (int i = 0; i < t; i++) {
    int l = 0, r = q - 1;
    while (l <= r) {
      int m = (l + r) / 2;
      if (a[m] < b[i])
        l = m + 1;
      else if (a[m] > b[i])
        r = m - 1;
      else if (a[m] == b[i]) {
        n++;
        break;
      }
    }
  }

  cout << n << endl;
}

#include <algorithm>
#include <iostream>
#define SIZE 100000
#define SIZE2 50000
using namespace std;

bool compare(int a, int b) { return a < b; }

int a[SIZE];
int b[SIZE2];
int main() {
  int q;

  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> a[i];
  }

  sort(a, a + q, compare);

  int t;
  cin >> t;
  for (int j = 0; j < t; j++) {
    cin >> b[j];
  }

  int n = 0;
  for (int i = 0; i < t; i++) {
    int l = 0, r = q - 1;
    while (l <= r) {
      int m = (l + r) / 2;
      if (a[m] < b[i])
        l = m + 1;
      else if (a[m] > b[i])
        r = m - 1;
      else if (a[m] == b[i]) {
        n++;
        break;
      }
    }
  }

  cout << n << endl;
}


#include <cstdio>

int main(int argc, char const *argv[]) {
  int n, q, target;
  int findCount = 0; // ???????????£?????°????????°
  int inputSequence[10000];

  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &inputSequence[i]);
  }

  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d", &target);
    int begin = 0, end = n - 1;
    do {
      int current = (begin + end) / 2;
      if (inputSequence[current] == target) {
        findCount++;
        break;
      }
      // ?????????????????§????????????????????????
      else if (inputSequence[current] < target) {
        begin = current + 1;
      }
      // ????????????????°?????????????????????????
      else if (inputSequence[current] > target) {
        end = current - 1;
      }
    } while (begin <= end); // ????????¨????°??????\\???????????£????????????
  }

  printf("%d\\n", findCount);
  return 0;
}

#include <cstdio>

int main(int argc, char const *argv[]) {
  int n, q, target;
  int findCount = 0; // ???????????£?????°????????°
  int inputSequence[100000];

  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &inputSequence[i]);
  }

  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d", &target);
    int begin = 0, end = n - 1;
    do {
      int current = (begin + end) / 2;
      if (inputSequence[current] == target) {
        findCount++;
        break;
      }
      // ?????????????????§????????????????????????
      else if (inputSequence[current] < target) {
        begin = current + 1;
      }
      // ????????????????°?????????????????????????
      else if (inputSequence[current] > target) {
        end = current - 1;
      }
    } while (begin <= end); // ????????¨????°??????\\???????????£????????????
  }

  printf("%d\\n", findCount);
  return 0;
}


#include <iostream>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> s(n);
  FOR(i, 0, n) { cin >> s[i]; }

  int q;
  cin >> q;
  vector<int> t(q);
  int cnt = 0;
  FOR(i, 0, q) {
    cin >> t[i];
    int left = 0, right = n - 1;
    int mid;
    while (left < right) {
      mid = (left + right) / 2;
      if (t[i] == s[mid]) {
        cnt++;
        break;
      }
      if (t[i] > s[mid]) {
        left = mid;
        ;
      }
      if (t[i] < s[mid]) {
        right = mid;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}

#include <algorithm>
#include <iostream>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> s(n);
  FOR(i, 0, n) { cin >> s[i]; }

  int q;
  cin >> q;
  vector<int> t(q);
  int cnt = 0;
  FOR(i, 0, q) {
    cin >> t[i];
    if (*lower_bound(s.begin(), s.end(), t[i]) == t[i]) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


#include <iostream>
using namespace std;
int main() {

  int n, a[10000], m, b, result = 0, i, j;

  cin >> n;
  for (i = 0; i < n; i++)
    cin >> a[i];
  cin >> m;
  for (i = 0; i < m; i++) {
    cin >> b;
    for (j = 0; j < n; j++)
      if (b == a[j]) {
        result++;
        break;
      }
  }

  cout << result << endl;

  return 0;
}

#include <iostream>
using namespace std;
int main() {

  int n, a[100000], m, b, result = 0, i, j;

  cin >> n;
  for (i = 0; i < n; i++)
    cin >> a[i];
  cin >> m;
  for (i = 0; i < m; i++) {
    cin >> b;
    for (j = 0; j < n; j++)
      if (b == a[j]) {
        result++;
        break;
      }
  }

  cout << result << endl;

  return 0;
}


#include <iostream>
#include <vector>

#define r(i, n) for (int i = 0; i < n; i++)

using namespace std;

// input
vector<int> S, T;

int main() {
  // input
  int n, q;
  cin >> n;
  while (n--) {
    int a;
    cin >> a;
    S.push_back(a);
  }
  cin >> q;
  while (q--) {
    int a;
    cin >> a;
    T.push_back(a);
  }

  // linear search
  int C = 0;
  r(i, T.size()) {
    r(j, S.size()) {
      if (T[i] == S[j]) {
        C++;
        break;
      }
    }
  }

  cout << C << endl;
}

#include <algorithm>
#include <iostream>
#include <vector>

#define r(i, n) for (int i = 0; i < n; i++)

using namespace std;

// input
vector<int> S, T;

int main() {
  // input, S is ascending
  int n, q;
  cin >> n;
  while (n--) {
    int a;
    cin >> a;
    S.push_back(a);
  }
  cin >> q;
  while (q--) {
    int a;
    cin >> a;
    T.push_back(a);
  }

  // binary search
  int C = 0;
  r(i, T.size()) {
    if (binary_search(S.begin(), S.end(), T[i]))
      C++;
  }

  cout << C << endl;
}


#include <stdio.h>

#define N 10000

int S[N], T[N];
int n, m;

int binary() {
  int l, r, mid, i;
  int count = 0;
  for (i = 0; i < m; i++) {
    l = 0;
    r = n;
    while (l < r) {
      mid = (l + r) / 2;
      if (S[mid] == T[i]) {
        count++;
        l = r;
      } else if (T[i] < S[mid]) {
        r = mid;
      } else {
        l = mid + 1;
      }
    }
  }
  return count;
}

int main() {
  scanf("%d\\n", &n);
  int i;
  for (i = 0; i < n; i++) {
    scanf("%d", &S[i]);
  }
  scanf("%d\\n", &m);
  for (i = 0; i < m; i++) {
    scanf("%d", &T[i]);
  }

  int c = binary();

  printf("%d\\n", c);
  return 0;
}

#include <stdio.h>

#define N 100000

int S[N], T[N];
int n, m;

int binary() {
  int l, r, mid, i;
  int count = 0;
  for (i = 0; i < m; i++) {
    l = 0;
    r = n;
    while (l < r) {
      mid = (l + r) / 2;
      if (S[mid] == T[i]) {
        count++;
        l = r;
      } else if (T[i] < S[mid]) {
        r = mid;
      } else {
        l = mid + 1;
      }
    }
  }
  return count;
}

int main() {
  scanf("%d\\n", &n);
  int i;
  for (i = 0; i < n; i++) {
    scanf("%d", &S[i]);
  }
  scanf("%d\\n", &m);
  for (i = 0; i < m; i++) {
    scanf("%d", &T[i]);
  }

  int c = binary();

  printf("%d\\n", c);
  return 0;
}


#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
int main() {
  int n, q, ans;
  ans = 0;
  cin >> n;
  int s[n];
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  cin >> q;
  int t[q];
  for (int i = 0; i < q; i++) {
    cin >> t[i];
  }
  for (int i = 0; i < q; i++) {
    int left = 0;
    int right = n;
    int mid;
    while (left < right) {
      mid = (left + right) / 2;
      if (s[mid] == t[i]) {
        ans++;
        break;
      } else if (t[i] < s[mid])
        right = mid;
      else if (s[mid] < t[i])
        left = mid;
    }
  }
  cout << ans << endl;
}

#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
int main() {
  int n, q, ans;
  ans = 0;
  cin >> n;
  int s[n];
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  cin >> q;
  int t[q];
  for (int i = 0; i < q; i++) {
    cin >> t[i];
  }
  for (int i = 0; i < q; i++) {
    int left = 0;
    int right = n;
    int mid;
    while (left < right) {
      mid = (left + right) / 2;
      if (s[mid] == t[i]) {
        ans++;
        goto l;
      } else if (t[i] < s[mid])
        right = mid;
      else if (s[mid] < t[i])
        left = mid + 1;
    }
  l:;
  }
  cout << ans << endl;
}


#include <iostream>

using namespace std;

int main() {
  int S[100000], T[100000], n, q, key, low = 0, upper = 0, mid, flag;
  int i = 0, cnt = 0;

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> S[i];
  }
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> T[i];
  }

  for (i = 0; i < q; i++) {
    ///------------------------------
    key = T[i];
    low = 0;
    upper = 0;
    mid = 0;
    upper = n; // n-1

    mid = (low + upper) / 2;
    while (low <= upper) {
      // mid=(low+upper)/2;

      if (S[mid] == key) {

        flag = 1;
        cnt++;
        break;
      }

      if (S[mid] < key) {
        low = mid + 1;
      } else {
        upper = mid; // mid-1
      }
      mid = (low + upper) / 2; //
    }
    if (flag != 1) {
      // no
    }

    ///------------------------------
  }

  cout << cnt << endl;

  return 0;
}

#include <iostream>

using namespace std;

int main() {
  int S[100000], T[100000], n, q, key, low = 0, upper = 0, mid, flag;
  int i = 0, cnt = 0;

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> S[i];
  }
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> T[i];
  }

  for (i = 0; i < q; i++) {
    ///------------------------------
    key = T[i];
    low = 0;
    upper = 0;
    mid = 0;
    upper = n; // n-1

    mid = (low + upper) / 2;
    while (low < upper) {
      // mid=(low+upper)/2;

      if (S[mid] == key) {

        flag = 1;
        cnt++;
        break;
      }

      if (S[mid] < key) {
        low = mid + 1;
      } else {
        upper = mid; // mid-1
      }
      mid = (low + upper) / 2; //
    }
    if (flag != 1) {
      // no
    }

    ///------------------------------
  }

  cout << cnt << endl;

  return 0;
}


#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

int main(int argc, char const *argv[]) {
  int n;
  std::cin >> n;
  std::vector<int> S;
  S.reserve(100000);
  for (size_t i = 0; i < n; i++) {
    std::cin >> S[i];
  }

  int mid;
  if (n % 2 == 0) {
    mid = n / 2;
  } else {
    mid = (n - 1) / 2;
  }

  int num = 0;

  int q;
  std::cin >> q;
  int val;
  for (size_t i = 0; i < q; i++) {
    std::cin >> val;
    while (1) {
      if (val == S[mid]) {
        num++;
        break;
      }
      if (S[0] <= val && val <= S[mid - 1]) {
        mid = mid / 2;
      } else if (S[mid + 1] <= val && val <= S[n - 1]) {
        mid = (mid + n) / 2;
      } else {
        break;
      }
    }
  }
  std::cout << num << '\\n';

  return 0;
}

#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

int main(int argc, char const *argv[]) {
  int n, val, tmp;
  int len = 0;
  std::cin >> n;
  std::vector<int> S;
  S.reserve(100000);

  for (size_t i = 0; i < n; i++) {
    std::cin >> val;
    if (i == 0 || val != tmp) {
      len++;
      S[len] = val;
      tmp = val;
    }
  }

  int num = 0;

  int q;
  std::cin >> q;
  for (size_t i = 0; i < q; i++) {
    std::cin >> val;
    int lower = 0;
    int upper = len;
    int mid = upper / 2;
    while (1) {
      if (val == S[mid] || val == S[mid + 1] || val == S[mid - 1]) {
        num++;
        break;
      }
      if (S[0] <= val && val <= S[mid - 1]) {
        upper = mid;
        mid = (mid + lower) / 2;
      } else if (S[mid + 1] <= val && val <= S[upper]) {
        lower = mid;
        mid = (mid + upper) / 2;
      } else {
        break;
      }
    }
  }
  std::cout << num << '\\n';

  return 0;
}


#include <iostream>
#include <vector>

bool binary_search(std::vector<int>::iterator a, std::vector<int>::iterator b,
                   int key) {

  std::vector<int>::iterator x = a + (std::distance(a, b) / 2);
  if (*x == key)
    return true;
  if (std::distance(a, b) == 0)
    return false;
  if (*x < key)
    return binary_search(x + 1, b, key);
  if (*x > key)
    return binary_search(a, x - 1, key);
}

int main() {
  int n;
  std::cin >> n;

  std::vector<int> S;
  S.resize(n, 0);
  for (int i = 0; i < n; i++) {
    std::cin >> S[i];
  }

  int q;
  std::cin >> q;

  std::vector<int> T;
  T.resize(q, 0);
  for (int i = 0; i < q; i++) {
    std::cin >> T[i];
  }

  int cnt = 0;
  for (int i = 0; i < q; i++) {
    if (binary_search(S.begin(), S.end(), T[i]))
      cnt++;
  }

  std::cout << cnt << std::endl;

  return 0;
}

#include <algorithm>
#include <iostream>
#include <vector>

int main() {
  int n;
  std::cin >> n;

  std::vector<int> S;
  S.resize(n, 0);
  for (int i = 0; i < n; i++) {
    std::cin >> S[i];
  }

  int q;
  std::cin >> q;

  std::vector<int> T;
  T.resize(q, 0);
  for (int i = 0; i < q; i++) {
    std::cin >> T[i];
  }

  int cnt = 0;
  for (int i = 0; i < q; i++) {
    if (std::binary_search(S.begin(), S.end(), T[i]))
      cnt++;
  }

  std::cout << cnt << std::endl;

  return 0;
}


#include <iostream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
// 常に心してかかれ
// 簡単なことを簡単にできるように練習する
int main() {
  int n;
  int q;
  int tmp;
  int C = 0;
  int num_to_check;
  int S[10001];
  int head;
  int tail;
  int mid; // 中央値
  stack<int> T;

  cin >> n;

  for (int i = 0; i < n; i++) {
    scanf("%d", &S[i]);
  }

  /*確認
  for(int i=0;i<n;i++){
          cout <<S[i] <<" ";
  }
  cout <<endl;
  */

  cin >> q;

  for (int i = 0; i < q; i++) {
    scanf("%d", &tmp);
    T.push(tmp);
  }

  /*確認
  while(!T.empty()){
          cout <<T.top() <<" ";
          T.pop();
  }
  cout <<endl;
  */

  // 高速化用コード
  int j = 1;
  for (int i = 1; i < n; i++) {
    if (S[i] == S[i - 1]) {
      ;
    } else {
      j++;
      S[j] = S[i];
    }
  }
  n = j + 1;
  //

  while (!T.empty()) {
    num_to_check = T.top();
    T.pop();
    head = 0;
    tail = n - 1;

    // キーの探索
    while (head <= tail) {

      // 高速化用コード
      if (num_to_check < S[0] || num_to_check > S[n - 1])
        break;
      //

      if (head == tail) {
        if (num_to_check == S[head /*==tail*/]) {
          C++;
          break;
        } else {
          break;
        }
      }
      mid = (head + tail) / 2;
      if (num_to_check == S[mid]) { // 見つかった(中央の値と一致)
        C++;
        break;
      } else { // 中央の値と一致しない
        if (head == tail - 1) {
          if (num_to_check == S[head] || num_to_check == S[tail]) {
            C++;
            break;
          } else {
            break;
          }
        }
        if (num_to_check > S[mid]) { // 中央の値より大きい
          head = mid + 1;
          // cout <<"head" <<head <<"tail" <<tail <<endl;
        } else { // 中央の値より小さい
          tail = mid - 1;
          // cout <<"head" <<head <<"tail" <<tail <<endl;
        }
      }
    }
  }
  cout << C << endl;
  return 0;
}

#include <iostream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
// 常に心してかかれ
// 簡単なことを簡単にできるように練習する
int main() {
  int n;
  int q;
  int tmp;
  int C = 0;
  int num_to_check;
  int S[100001];
  int head;
  int tail;
  int mid; // 中央値
  stack<int> T;

  cin >> n;

  for (int i = 0; i < n; i++) {
    scanf("%d", &S[i]);
  }

  /*確認
  for(int i=0;i<n;i++){
          cout <<S[i] <<" ";
  }
  cout <<endl;
  */

  cin >> q;

  for (int i = 0; i < q; i++) {
    scanf("%d", &tmp);
    T.push(tmp);
  }

  /*確認
  while(!T.empty()){
          cout <<T.top() <<" ";
          T.pop();
  }
  cout <<endl;
  */

  // 高速化用コード
  int j = 1;
  for (int i = 1; i < n; i++) {
    if (S[i] == S[i - 1]) {
      ;
    } else {
      j++;
      S[j] = S[i];
    }
  }
  n = j + 1;
  //

  while (!T.empty()) {
    num_to_check = T.top();
    T.pop();
    head = 0;
    tail = n - 1;

    // キーの探索
    while (head <= tail) {

      // 高速化用コード
      if (num_to_check < S[0] || num_to_check > S[n - 1])
        break;
      //

      if (head == tail) {
        if (num_to_check == S[head /*==tail*/]) {
          C++;
          break;
        } else {
          break;
        }
      }
      mid = (head + tail) / 2;
      if (num_to_check == S[mid]) { // 見つかった(中央の値と一致)
        C++;
        break;
      } else { // 中央の値と一致しない
        if (head == tail - 1) {
          if (num_to_check == S[head] || num_to_check == S[tail]) {
            C++;
            break;
          } else {
            break;
          }
        }
        if (num_to_check > S[mid]) { // 中央の値より大きい
          head = mid + 1;
          // cout <<"head" <<head <<"tail" <<tail <<endl;
        } else { // 中央の値より小さい
          tail = mid - 1;
          // cout <<"head" <<head <<"tail" <<tail <<endl;
        }
      }
    }
  }
  cout << C << endl;
  return 0;
}


#include <algorithm>
#include <iostream>
#include <vector>

bool binary_search(std::vector<int>::iterator a, std::vector<int>::iterator b,
                   int key) {
  if (std::distance(a, b) == 0)
    return false;
  std::vector<int>::iterator mid = a + std::distance(a, b) / 2;
  if (*mid == key)
    return true;
  if (*mid < key)
    return binary_search(mid, b, key);
  else
    return binary_search(a, mid - 1, key);
}

int main() {
  int n;
  std::cin >> n;

  std::vector<int> S;
  S.resize(n, 0);
  for (int i = 0; i < n; i++) {
    std::cin >> S[i];
  }

  int q;
  std::cin >> q;

  std::vector<int> T;
  T.resize(q, 0);
  for (int i = 0; i < q; i++) {
    std::cin >> T[i];
  }

  int cnt = 0;
  for (int i = 0; i < q; i++) {
    if (binary_search(S.begin(), S.end(), T[i]))
      cnt++;
  }

  std::cout << cnt << std::endl;

  return 0;
}

#include <algorithm>
#include <iostream>
#include <vector>

bool binary_search(std::vector<int>::iterator a, std::vector<int>::iterator b,
                   int key) {
  if (std::distance(a, b) == 0)
    return false;
  std::vector<int>::iterator mid = a + std::distance(a, b) / 2;
  if (*mid == key)
    return true;
  if (*mid < key)
    return binary_search(mid + 1, b, key);
  else
    return binary_search(a, mid, key);
}

int main() {
  int n;
  std::cin >> n;

  std::vector<int> S;
  S.resize(n, 0);
  for (int i = 0; i < n; i++) {
    std::cin >> S[i];
  }

  int q;
  std::cin >> q;

  std::vector<int> T;
  T.resize(q, 0);
  for (int i = 0; i < q; i++) {
    std::cin >> T[i];
  }

  int cnt = 0;
  for (int i = 0; i < q; i++) {
    if (binary_search(S.begin(), S.end(), T[i]))
      cnt++;
  }

  std::cout << cnt << std::endl;

  return 0;
}


#include <iostream>
#include <vector>
using namespace std;

bool lsearch(int A[], int n, int val) {
  for (int i = 0; i < n; i++) {
    if (A[i] == val)
      return true;
  }
  return false;
}

int main() {
  int n, A[10001];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }

  int q, val, sum = 0;
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> val;
    if (lsearch(A, n, val))
      sum++;
  }

  cout << sum << endl;
}

#include <iostream>
#include <vector>
using namespace std;
int n, S[1000000];

int binarySearch(int val) {
  int left = 0, right = n;
  while (left < right) {
    int mid = (left + right) / 2;
    if (S[mid] == val) {
      // cout << val;
      return mid;
    } else if (val < S[mid]) {
      right = mid;
    } else {
      left = mid + 1;
    }
  }
  return -1;
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> S[i];
  }

  int q, val, sum = 0;
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> val;
    if (binarySearch(val) >= 0) {
      sum++;
    }
  }

  cout << sum << endl;
}


#include <bits/stdc++.h>
using namespace std;
struct cww {
  cww() {
    ios::sync_with_stdio(false);
    cin.tie(0);
  }
} star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i, a, n) for (int i = (a), i##_len = (n); i < i##_len; ++i)
#define rrep(i, a, n) for (int i = (a); i > n; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
inline int f(int n, vi s, int q, vi t) {
  int cnt = 0;
  rep(j, 0, q) {
    if (count(all(s), t[j]))
      ++cnt;
  }
  return cnt;
}
int main() {
  int n;
  cin >> n;
  unordered_set<int> ss;
  {
    ll t;
    rep(i, 0, n) {
      cin >> t;
      ss.emplace(t);
    }
  }
  vi s(all(ss));
  int q;
  cin >> q;
  vi t(q);
  rep(i, 0, q) cin >> t[i];
  P(f(len(s), s, q, t));
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
struct cww {
  cww() {
    ios::sync_with_stdio(false);
    cin.tie(0);
  }
} star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i, a, n) for (int i = (a), i##_len = (n); i < i##_len; ++i)
#define rrep(i, a, n) for (int i = (a); i > n; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
inline int f(int n, vi s, int q, vi t) {
  int cnt = 0;
  rep(j, 0, q) {
    if (find(all(s), t[j]) != s.end())
      ++cnt;
  }
  return cnt;
}
int main() {
  int n;
  cin >> n;
  unordered_set<int> ss;
  {
    ll t;
    rep(i, 0, n) {
      cin >> t;
      ss.emplace(t);
    }
  }
  vi s(all(ss));
  int q;
  cin >> q;
  vi t(q);
  rep(i, 0, q) cin >> t[i];
  P(f(len(s), s, q, t));
  return 0;
}


/*http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_B&lang=jp*/

#include <iostream>
#include <vector>

using namespace std;

int mybinarysearch(vector<int> s, int value, int max, int min) {
  int mid = (max + min) / 2;

  if (max <= min) {
    return 0;
  } else if (s[mid] == value) {
    return 1;
  } else if (s[mid] < value) {
    return mybinarysearch(s, value, max, mid + 1);
  } else {
    return mybinarysearch(s, value, mid, min);
  }
}

int main() {
  int count = 0;
  int n, q;
  vector<int> s;

  cin >> n;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    s.push_back(tmp);
  }
  cin >> q;
  for (int i = 0; i < q; i++) {
    int tmp;
    cin >> tmp;
    count += mybinarysearch(s, tmp, s.size(), 0);
  }
  cout << count << endl;
  return 0;
}

/*http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_B&lang=jp*/

#include <iostream>
#include <vector>

using namespace std;

vector<int> s;

int mybinarysearch(int value, int max, int min) {
  int mid = (max + min) / 2;

  if (max <= min) {
    return 0;
  } else if (s[mid] == value) {
    return 1;
  } else if (s[mid] < value) {
    return mybinarysearch(value, max, mid + 1);
  } else {
    return mybinarysearch(value, mid, min);
  }
}

int main() {
  int count = 0;
  int n, q;

  cin >> n;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    s.push_back(tmp);
  }
  cin >> q;
  for (int i = 0; i < q; i++) {
    int tmp;
    cin >> tmp;
    count += mybinarysearch(tmp, s.size(), 0);
  }
  cout << count << endl;
  return 0;
}


#include <iostream>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> s(n);
  FOR(i, 0, n) { cin >> s[i]; }

  int q;
  cin >> q;
  vector<int> t(q);
  int cnt = 0;
  FOR(i, 0, q) {
    cin >> t[i];
    int left = 0, right = n - 1;
    int mid;
    while (left < right) {
      mid = (left + right) / 2;
      if (t[i] == s[mid]) {
        cnt++;
        break;
      }
      if (t[i] > s[mid]) {
        left = mid;
      }
      if (t[i] < s[mid]) {
        right = mid;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}

#include <iostream>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> s(n);
  FOR(i, 0, n) { cin >> s[i]; }

  int q;
  cin >> q;
  vector<int> t(q);
  int cnt = 0;
  FOR(i, 0, q) {
    cin >> t[i];
    int left = 0, right = n;
    int mid;
    while (left < right) {
      mid = (left + right) / 2;
      if (t[i] == s[mid]) {
        cnt++;
        break;
      }
      if (t[i] > s[mid]) {
        left = mid + 1;
      }
      if (t[i] < s[mid]) {
        right = mid;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}


#include <cstdio>
#include <iostream>

using namespace std;

int main(void) {

  int n;
  cin >> n;

  int *S = new int[n];
  for (int i = 0; i < n; ++i) {
    cin >> S[i];
  }

  int q;
  cin >> q;

  int total = 0;
  for (int i = 0; i < q; ++i) {
    int x;
    cin >> x;
    for (int j = 0; j < n; ++j) {
      if (x == S[j]) {
        ++total;
        break;
      }
    }
  }

  printf("%d\\n", total);

  return 0;
}

#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;

int S[100000];

int main(void) {

  int n;
  cin >> n;

  for (int i = 0; i < n; ++i) {
    cin >> S[i];
  }

  int q, total = 0;
  cin >> q;
  for (int i = 0; i < q; ++i) {
    int t;
    cin >> t;
    int left = 0, right = n - 1, mid = 0;
    while (left <= right) { // '<' ?????¨?????¨??§?????????
      mid = (left + right) / 2;
      if (t == S[mid]) {
        ++total;
        break;
      }
      if (t > S[mid]) {
        left = mid + 1;
      } else {
        right = mid - 1;
      }
    }
  }

  printf("%d\\n", total);

  return 0;
}


#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int n, q;
vector<int> s(n);
vector<int> t(q);

int binarysearch(int key) {
  int left = 0;
  int right = n;
  int mid;
  while (left < right) {
    mid = (left + right) / 2;
    if (key == s[mid])
      return 1;
    if (key > s[mid])
      left = mid + 1;
    else if (key < s[mid])
      right = mid;
  }
  return 0;
}

int main() {
  int ans = 0;
  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  cin >> q;

  for (int j = 0; j < q; j++) {
    cin >> t[j];
    if (binarysearch(t[j])) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int ans = 0, n;
vector<int> s;

void binarysearch(int key) {
  int left = 0, right = n, mid;
  while (left < right) {
    mid = (left + right) / 2;
    if (s[mid] == key) {
      ans++;
      return;
    } else if (key < s[mid])
      right = mid;
    else
      left = mid + 1;
  }
  return;
}

int main() {
  cin >> n;
  s.resize(n);
  for (int i = 0; i < n; i++)
    cin >> s[i];
  int q;
  cin >> q;
  vector<int> t(q);
  for (int i = 0; i < q; i++) {
    cin >> t[i];
    binarysearch(t[i]);
  }
  cout << ans << endl;
  return 0;
}


#include <iostream>

#define N_MAX 100001
#define Q_MAX 50000
int count = 0;
int n, q;
int s_array[N_MAX], t_array[Q_MAX];
void down_heap(int array[], int, int);

void printArray(int array[], int n) {
  for (int i = 1; i <= n; i++) {
    std::cout << array[i] << ' ';
  }
  std::cout << '\\n';
}

void sort(int array[], int n) {
  int length = n;
  for (int i = length / 2; i > 0; i--) {
    down_heap(array, length, i);
  }
  while (length != 1) {
    array[0] = array[1];
    array[1] = array[length];
    array[length] = array[0];
    length--;
    for (int i = length / 2; i > 0; i--) {
      down_heap(array, length, i);
    }
  }
}

void down_heap(int array[], int length, int k) {
  int child;

  while (k <= length / 2) {

    child = 2 * k;
    if (child + 1 <= length && array[child] < array[child + 1]) {
      child += 1;
    }

    if (array[k] < array[child]) {
      array[0] = array[k];
      array[k] = array[child];
      array[child] = array[0];
      k = child;

    } else {
      break;
    }
  }
}
void search(int k, int left, int right) {
  while (left <= right) {
    int center = (left + right) / 2;
    if (s_array[center] == k) {
      count++;
      return;
    } else if (s_array[center] < k) {
      left = center + 1;
    } else if (s_array[center] > k) {
      right = center - 1;
    }
  }
}

int main() {

  std::cin >> n;
  for (int i = 1; i <= n; i++) {
    std::cin >> s_array[i];
  }
  // printArray(s_array,n);

  sort(s_array, n);

  // printArray(s_array,n);

  std::cin >> q;
  for (int i = 0; i < q; i++) {
    std::cin >> t_array[i];
    search(t_array[i], 1, n);
  }

  std::cout << count << '\\n';

  return 0;
}

#include <iostream>

#define N_MAX 100001
#define Q_MAX 50000
int count = 0;
int n, q;
int s_array[N_MAX], t_array[Q_MAX];
void down_heap(int array[], int, int);

void printArray(int array[], int n) {
  for (int i = 1; i <= n; i++) {
    std::cout << array[i] << ' ';
  }
  std::cout << '\\n';
}

void sort(int array[], int n) {
  int length = n;
  for (int i = length / 2; i > 0; i--) {
    down_heap(array, length, i);
  }
  while (length != 1) {
    array[0] = array[1];
    array[1] = array[length];
    array[length] = array[0];
    length--;
    for (int i = length / 2; i > 0; i--) {
      down_heap(array, length, i);
    }
  }
}

void down_heap(int array[], int length, int k) {
  int child;

  while (k <= length / 2) {

    child = 2 * k;
    if (child + 1 <= length && array[child] < array[child + 1]) {
      child += 1;
    }

    if (array[k] < array[child]) {
      array[0] = array[k];
      array[k] = array[child];
      array[child] = array[0];
      k = child;

    } else {
      break;
    }
  }
}
void search(int k, int left, int right) {
  while (left <= right) {
    int center = (left + right) / 2;
    if (s_array[center] == k) {
      count++;
      return;
    } else if (s_array[center] < k) {
      left = center + 1;
    } else if (s_array[center] > k) {
      right = center - 1;
    }
  }
}

int main() {
  int max = 0;

  std::cin >> n;
  for (int i = 1; i <= n; i++) {
    std::cin >> s_array[i];
    if (s_array[i] < max) {
      sort(s_array, i);
    }
  }
  // printArray(s_array,n);

  // sort(s_array,n);

  // printArray(s_array,n);

  std::cin >> q;
  for (int i = 0; i < q; i++) {
    std::cin >> t_array[i];
    search(t_array[i], 1, n);
  }

  std::cout << count << '\\n';

  return 0;
}


// 線形探索
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <stack>

using namespace std;

const int MAX_N = 100000;
// const int MAX_Q = 500;

bool linearSearch(int A[], int n, int key);

int main(void) {

  int n, q, key, count = 0;
  int ary_N[MAX_N + 1];

  scanf("%d", &n);

  for (int i = 0; i < n; i++) {
    scanf("%d", &ary_N[i]);
  }

  scanf("%d", &q);

  for (int i = 0; i < q; i++) {
    scanf("%d", &key);

    if (linearSearch(&ary_N[0], n, key) == true) {
      count++;
    }
  }

  printf("%d\\n", count);

  return 0;
}

// 線形探索
bool linearSearch(int A[], int n, int key) {
  int i = 0;
  // 終了条件の番兵の代入
  A[n] = key;

  while (A[i] != key) {
    i++;
  }

  return i != n;
}

// 2分探索
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <stack>

using namespace std;

const int MAX_N = 1000000;
// const int MAX_Q = 500;

bool Binary_Search(int A[], int n, int key);

int main(void) {

  int n, q, key, count = 0;
  int ary_N[MAX_N + 1];

  scanf("%d", &n);

  for (int i = 0; i < n; i++) {
    scanf("%d", &ary_N[i]);
  }

  scanf("%d", &q);

  for (int i = 0; i < q; i++) {
    scanf("%d", &key);

    if (Binary_Search(&ary_N[0], n, key) == true) {
      count++;
    }
  }

  printf("%d\\n", count);

  return 0;
}

// 2分探索
bool Binary_Search(int A[], int n, int key) {
  bool ret = false;

  int left, right, mid;

  left = 0;
  right = n;
  mid = (left + right) / 2;

  while (left < right) {
    if (A[mid] < key) {
      // 後半を探索
      left = mid + 1;
    } else if (A[mid] > key) {
      // 前半を探索
      right = mid;
    } else {
      ret = true;
      // 値が見つかったので処理終了
      break;
    }

    mid = (left + right) / 2;
  }

  return ret;
}


#include <fstream>
#include <iostream>
using namespace std;

bool binarySearch(int s[], int begin, int end, int t);

int main() {
  int i, j, n, q, s[100001], t, cnt = 0;
  ifstream fin("ALDS1_4_B-in8.txt");
  if (!fin) {
    cout << "failed to open the file.";
    return 1;
  }
  fin >> n;
  for (i = 0; i < n; i++) {
    fin >> s[i];
  }
  fin >> q;
  for (j = 0; j < q; j++) {
    fin >> t;
    if (binarySearch(s, 0, n, t) == true)
      cnt++;
  }
  cout << cnt << endl;
  fin.close();
  return 0;
}

bool binarySearch(int s[], int begin, int end, int t) {
  int mid = (begin + end) / 2;
  if (t == s[mid])
    return true;
  else if (begin >= end)
    return false;
  else if (t < s[mid])
    return binarySearch(s, begin, mid - 1, t);
  else if (t > s[mid])
    return binarySearch(s, mid + 1, end, t);
}

#include <iostream>
// #include<fstream>
using namespace std;

bool binarySearch(int s[], int begin, int end, int t);

int main() {
  int i, j, n, q, s[100001], t, cnt = 0;
  // ifstream fin("ALDS1_4_B-in8.txt");
  // if (!fin) {
  //	cout << "failed to open the file.";
  //	return 1;
  // }
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> s[i];
  }
  cin >> q;
  for (j = 0; j < q; j++) {
    cin >> t;
    if (binarySearch(s, 0, n, t) == true)
      cnt++;
  }
  cout << cnt << endl;
  // fin.close();
  return 0;
}

bool binarySearch(int s[], int begin, int end, int t) {
  int mid = (begin + end) / 2;
  if (t == s[mid])
    return true;
  else if (begin >= end)
    return false;
  else if (t < s[mid])
    return binarySearch(s, begin, mid - 1, t);
  else if (t > s[mid])
    return binarySearch(s, mid + 1, end, t);
}


#include <stdio.h>
#define N 100000
int count = 0;
void BinarySearch(int array[], int right, int left, int key) {
  int mid = (right + left) / 2;
  if (left > right) {
    return;
  }

  if (array[mid] == key) {
    count++;
    return;
  } else if (array[mid] < key) {
    BinarySearch(array, right, mid + 1, key);
  } else {
    BinarySearch(array, mid, left, key);
  }
}

int main() {
  int i, n, array[N];
  scanf("%d", &n);
  for (i = 0; i < n; i++)
    scanf("%d", &array[i]);
  int m;
  scanf("%d", &m);
  for (i = 0; i < m; i++) {
    int l;
    scanf("%d", &l);
    BinarySearch(array, n, 0, l);
  }
  printf("%d\\n", count);
}

#include <stdio.h>
#define N 100000
int count = 0;
void BinarySearch(int array[], int right, int left, int key) {
  while (left < right) {
    int mid = (left + right) / 2;
    if (array[mid] == key) {
      count++;
      break;
    } else if (array[mid] < key) {
      left = mid + 1;
    } else {
      right = mid;
    }
  }
}

int main() {
  int i, n, array[N];
  scanf("%d", &n);
  for (i = 0; i < n; i++)
    scanf("%d", &array[i]);
  int m;
  scanf("%d", &m);
  for (i = 0; i < m; i++) {
    int l;
    scanf("%d", &l);
    BinarySearch(array, n, 0, l);
  }
  printf("%d\\n", count);
}


#include <algorithm>
#include <chrono>
#include <cmath>
#include <cstring>
#include <fstream>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

class cBinarySearch {
  int mn, mq;
  string mS, mT;
  int ans;
  vector<int> vs, vt;

  void decode();

public:
  cBinarySearch(const int &n, const int &q, const string &s, const string &t) {
    mn = n;
    mq = q;
    mS = s;
    mT = t;
    ans = 0;

    decode();
  }
  void search();
  void output();
};

void cBinarySearch::search() {
  int b, pb;
  int count = 0;
  for (int i = 0; i < vt.size(); ++i) {
    b = vs.size() / 2;
    pb = 0;
    while (b >= 0) {
      if (vt[i] == vs[b]) {
        ++count;
        break;
      } else {
        if (pb != b && vt[i] > vs[b]) {
          pb = b;
          b = b / 2 + vs.size() / 2;
        } else if (pb != b && vt[i] < vs[b]) {
          pb = b;
          b = b / 2;
        } else if (pb == b) {
          break;
        }
      }
    }
  }
  ans = count;
}

void cBinarySearch::output() { cout << ans << endl; }

void cBinarySearch::decode() {
  istringstream iss;
  iss.str(mS);
  int ts;
  for (int i = 0; i < mn; ++i) {
    iss >> ts;
    vs.push_back(ts);
  }
  iss.str(mT);
  iss.seekg(0, iss.beg);
  for (int i = 0; i < mq; ++i) {
    iss >> ts;
    vt.push_back(ts);
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n, q;
  string s, t;
  cin >> n;
  cin.ignore();
  getline(cin, s);
  cin >> q;
  cin.ignore();
  getline(cin, t);

  cBinarySearch cbs(n, q, s, t);
  cbs.search();
  cbs.output();

  return 0;
}

#include <algorithm>
#include <chrono>
#include <cmath>
#include <cstring>
#include <fstream>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

class cBinarySearch {
  int mn, mq;
  string mS, mT;
  int ans;
  vector<int> vs, vt;

  void decode();

public:
  cBinarySearch(const int &n, const int &q, const string &s, const string &t) {
    mn = n;
    mq = q;
    mS = s;
    mT = t;
    ans = 0;

    decode();
  }
  void search();
  void output();
};

void cBinarySearch::search() {
  int l, r, m;
  int count = 0;

  for (int i = 0; i < vt.size(); ++i) {
    l = 0;
    r = vs.size();
    m = (l + r) / 2;
    while (l < r) {
      m = (l + r) / 2;
      if (vt[i] == vs[m]) {
        ++count;
        break;
      } else if (vt[i] < vs[m]) {
        r = m;
      } else
        l = m + 1;
    }
  }
  ans = count;
}

void cBinarySearch::output() { cout << ans << endl; }

void cBinarySearch::decode() {
  istringstream iss;
  iss.str(mS);
  int ts;
  for (int i = 0; i < mn; ++i) {
    iss >> ts;
    vs.push_back(ts);
  }
  iss.str(mT);
  iss.seekg(0, iss.beg);
  for (int i = 0; i < mq; ++i) {
    iss >> ts;
    vt.push_back(ts);
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n, q;
  string s, t;
  cin >> n;
  cin.ignore();
  getline(cin, s);
  cin >> q;
  cin.ignore();
  getline(cin, t);

  cBinarySearch cbs(n, q, s, t);
  cbs.search();
  cbs.output();

  return 0;
}


#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)

int main() {
  ios_base::sync_with_stdio(false);

  unsigned int list[100000];
  int numOfList;

  cin >> numOfList;

  rep(i, numOfList) cin >> list[i];

  int val;
  int counter = 0;
  cin >> val;

  while (cin >> val) {
    int high = numOfList - 1;
    int low = 0;
    int mid;

    while (low <= high) {
      if (list[mid] < val) {
        low = mid + 1;
      } else if (list[mid] > val) {
        high = mid - 1;
      } else if (list[mid] == val) {
        counter++;
        break;
      }
    }
  }
  cout << counter << endl;

  return 0;
}

#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)

int main() {
  ios_base::sync_with_stdio(false);

  unsigned int list[100000];
  int numOfList;

  cin >> numOfList;

  rep(i, numOfList) cin >> list[i];

  int val;
  int counter = 0;
  cin >> val;

  while (cin >> val) {
    int high = numOfList - 1;
    int low = 0;
    int mid;

    while (low <= high) {
      mid = (low + high) / 2;
      if (list[mid] < val) {
        low = mid + 1;
      } else if (list[mid] > val) {
        high = mid - 1;
      } else if (list[mid] == val) {
        counter++;
        break;
      }
    }
  }
  cout << counter << endl;

  return 0;
}


#include <algorithm>
#include <iostream>
using namespace std;

int binarySearch(int A[], int n, int key) {
  size_t left = 0;
  size_t right = n;
  size_t mid = (left + right) / 2;
  while (left < right) {
    if (A[mid] == key)
      return 1;
    if (A[mid] < key)
      left = mid + 1;
    else if (A[mid] > key)
      right = mid;
  }
  return 0;
}

int main() {
  int n, q;
  int S[100'000];
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> S[i];
  cin >> q;
  int key;
  int count = 0;
  for (int i = 0; i < q; i++) {
    cin >> key;
    if (binarySearch(S, n, key))
      count++;
  }

  cout << count << endl;
}

#include <algorithm>
#include <iostream>
using namespace std;

int binarySearch(int A[], int n, int key) {
  size_t left = 0;
  size_t right = n;
  size_t mid = (left + right) / 2;
  while (left < right) {
    mid = (left + right) / 2;
    if (A[mid] == key)
      return 1;
    if (A[mid] < key)
      left = mid + 1;
    else if (A[mid] > key)
      right = mid;
  }
  return 0;
}

int main() {
  int n, q;
  int S[100'000];
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> S[i];
  cin >> q;
  int key;
  int count = 0;
  for (int i = 0; i < q; i++) {
    cin >> key;
    if (binarySearch(S, n, key))
      count++;
  }

  cout << count << endl;
}


#include <iostream>

using namespace std;

int b[10 ^ 9 + 1];

int main() {
  int n, q, s, t;
  int ans = 0;

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s;
    b[s]++;
  }
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> t;
    if (b[t] >= 1)
      ans++;
  }
  cout << ans << endl;
  return (0);
}

#include <iostream>

using namespace std;

int b[1000000010];

int main() {
  int n, q, s, t;
  int ans = 0;

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s;
    b[s]++;
  }
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> t;
    if (b[t] >= 1)
      ans++;
  }
  cout << ans << endl;
  return (0);
}


#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n = 0;
  cin >> n;
  vector<long> S;
  for (int i = 0; i < n; i++) {
    long buf = 0;
    cin >> buf;
    if (find(S.begin(), S.end(), buf) == S.end())
      S.push_back(buf);
  }
  sort(S.begin(), S.end());

  int q = 0;
  cin >> q;
  vector<long> T;
  for (int i = 0; i < q; i++) {
    long buf = 0;
    cin >> buf;
    T.push_back(buf);
  }
  sort(T.begin(), T.end());

  int n_count = 0;

  vector<long>::iterator itS = S.begin();

  while (itS != S.end()) {
    if (T.end() != find(T.begin(), T.end(), *itS))
      n_count++;
    itS++;
  }

  cout << n_count << '\\n';

  return 0;
}

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n = 0;
  cin >> n;
  vector<long> S;
  for (int i = 0; i < n; i++) {
    long buf = 0;
    cin >> buf;
    if (find(S.begin(), S.end(), buf) == S.end())
      S.push_back(buf);
  }
  sort(S.begin(), S.end());

  int q = 0;
  cin >> q;
  vector<long> T;
  for (int i = 0; i < q; i++) {
    long buf = 0;
    cin >> buf;
    T.push_back(buf);
  }
  sort(T.begin(), T.end());

  int n_count = 0;

  vector<long>::iterator itS, itT;
  for (itS = S.begin(), itT = T.begin(); itS != S.end() || itT != T.end();
       itS++) {
    if (*itS > *itT) {
      vector<long>::iterator pos = find(itT, T.end(), *itS);
      if (pos != T.end())
        itT = pos;
    }
    if (*itS == *itT) {
      n_count++;
      itT++;
    }
  }

  cout << n_count << '\\n';

  return 0;
}


#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

// binary search

int main() {
  ios::sync_with_stdio(false);
  int M, N;
  vector<int> u, v;

  // input
  cin >> M;
  for (int i = 0; i < M; ++i) {
    int m;
    cin >> m;
    u.push_back(m);
  }

  cin >> N;
  for (int i = 0; i < N; ++i) {
    int n;
    cin >> n;
    v.push_back(n);
  }

  // calc
  int res = 0;

  vector<int> &l = (M >= N ? u : v);
  vector<int> &s = (M >= N ? v : u);

  for (auto x : s) {
    // if(find(l.begin(), l.end(), x) != l.end()){
    //   ++res;
    // }
    bool found_flg = false;
    int bgn = 0;
    int end = l.size();
    int mid = (bgn + end) / 2;
    while (bgn < end) {
      if (l[mid] < x) {
        end = mid;
      } else if (l[mid] > x) {
        bgn = mid + 1;
      } else { // l[mid] == x
        found_flg = true;
        break;
      }
    }
    if (found_flg)
      ++res;
  }

  cout << res << endl;
}

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

// binary search

int main() {
  ios::sync_with_stdio(false);
  int M, N;
  vector<int> u, v;

  // input
  cin >> M;
  for (int i = 0; i < M; ++i) {
    int m;
    cin >> m;
    u.push_back(m);
  }

  cin >> N;
  for (int i = 0; i < N; ++i) {
    int n;
    cin >> n;
    v.push_back(n);
  }

  // calc
  int res = 0;

  // vector<int>& l = (M >= N ? u : v);
  // vector<int>& s = (M >= N ? v : u);
  vector<int> &l = u;
  vector<int> &s = v;

  for (auto x : s) {
    // if(find(l.begin(), l.end(), x) != l.end()){
    //   ++res;
    // }
    bool found_flg = false;
    int bgn = 0;
    int end = l.size();
    while (bgn < end) {
      int mid = (bgn + end) / 2;
      if (l[mid] > x) {
        end = mid;
      } else if (l[mid] < x) {
        bgn = mid + 1;
      } else { // l[mid] == x
        found_flg = true;
        break;
      }
    }
    if (found_flg)
      ++res;
  }

  cout << res << endl;
}


#include <iostream>
#include <memory>
#include <vector>

using namespace std;

bool bin(vector<int> d, int l, int r, int key) {
  // cout<<"bin r:"<<r<<" l:"<<l<<" key:"<<key<<endl;

  if (d[r] == key)
    return true;
  if (d[l] == key)
    return true;
  if (r == l)
    return false;

  int m = (l + r) / 2;

  if (d[m] < key) {
    l = m + 1;
  } else if (d[m] > key) {
    r = m;
  } else {
    return true;
  }
  if (bin(d, l, r, key))
    return true;
  return false;
}

int main() {

  vector<int> dat;
  int n, itmp;
  cin >> n;

  for (int i = 0; i < n; ++i) {
    cin >> itmp;
    dat.push_back(itmp);
  }

  int q, count = 0;
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> itmp;
    if (bin(dat, 0, n - 1, itmp)) {
      //          cout<<" item:"<<itmp<<endl;
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

#include <iostream>
#include <memory>
#include <vector>

using namespace std;

vector<int> d;

bool bin(int l, int r, int key) {
  int mid;
  while (l < r) {
    mid = (l + r) / 2;
    if (d[mid] == key) {
      return mid;
    } else if (key < d[mid]) {
      r = mid;
    } else {
      l = mid + 1;
    }
  }
  return false;
}

int main() {

  int n, itmp;
  cin >> n;

  for (int i = 0; i < n; ++i) {
    cin >> itmp;
    d.push_back(itmp);
  }

  int q, count = 0;
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> itmp;
    if (bin(0, n, itmp)) {
      //          cout<<" item:"<<itmp<<endl;
      count++;
    }
  }
  cout << count << endl;
  return 0;
}


#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> s;
  for (int i = 0; i < n; i++) {
    s.push_back(i);
    cin >> s[i];
  }
  sort(s.begin(), s.end());
  int q;
  cin >> q;
  vector<int> t;
  for (int i = 0; i < q; i++) {
    t.push_back(i);
    cin >> t[i];
  }
  sort(t.begin(), t.end());
  int c = 0;
  for (int j = 0; j < q; j++) {
    for (int i = 0; i < n; i++) {
      if (s[i] == t[j])
        c++;
      if (s[i] >= t[j])
        break;
    }
  }
  cout << c << endl;
  return 0;
}

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> s;
  for (int i = 0; i < n; i++) {
    s.push_back(i);
    cin >> s[i];
  }
  sort(s.begin(), s.end());
  int q;
  cin >> q;
  vector<int> t;
  for (int i = 0; i < q; i++) {
    t.push_back(i);
    cin >> t[i];
  }
  sort(t.begin(), t.end());
  int c = 0;
  int i = 0;
  for (int j = 0; j < q; j++) {
    while (true) {
      if (s[i] == t[j])
        c++;
      if (s[i] >= t[j])
        break;
      i++;
      if (i == n)
        break;
    }
    if (i == n)
      break;
  }
  cout << c << endl;
  return 0;
}


#include <cstdio>
#include <iostream>

using namespace std;
int A[10000], B[10000], NA, NB;

int binarysearch(int key) {
  int left = 0, right = NA - 1;
  while (left <= right) {
    int mid = (left + right) / 2;
    if (A[mid] == key)
      return 1;
    else if (A[mid] < key)
      left = mid + 1;
    else
      right = mid - 1;
  }
  return 0;
}

int main() {
  int sum = 0;
  cin >> NA;
  for (int i = 0; i < NA; i++) {
    cin >> A[i];
  }
  cin >> NB;
  for (int i = 0; i < NB; i++) {
    cin >> B[i];
    if (binarysearch(B[i]))
      sum++;
  }
  cout << sum << endl;
  return 0;
}

#include <cstdio>
#include <iostream>

using namespace std;
int A[100000], B[100000], NA, NB;

int binarysearch(int key) {
  int left = 0, right = NA - 1;
  while (left <= right) {
    int mid = (left + right) / 2;
    if (A[mid] == key)
      return 1;
    else if (A[mid] < key)
      left = mid + 1;
    else
      right = mid - 1;
  }
  return 0;
}

int main() {
  int sum = 0;
  cin >> NA;
  for (int i = 0; i < NA; i++) {
    cin >> A[i];
  }
  cin >> NB;
  for (int i = 0; i < NB; i++) {
    cin >> B[i];
    if (binarysearch(B[i]))
      sum++;
  }
  cout << sum << endl;
  return 0;
}