#include <iostream>
#include <stdio.h>
using namespace std;

int binarySearch(int A[], int s, int t, int key);

int main() {
  int n, S[100000], q, T[50000], key, C = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%d", &S[i]);
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d", &key);
    C += binarySearch(S, 0, n, key);
  }
  printf("%d\\n", C);
  return 0;
}

int binarySearch(int A[], int s, int t, int key) {
  int i = (t - s) / 2;
  return (A[i] == key  ? true
          : i == 0     ? false
          : A[i] < key ? binarySearch(A, i, t, key)
                       : binarySearch(A, 0, i, key));
}

#include <iostream>
#include <stdio.h>
using namespace std;

int binarySearch(int A[], int n, int key);

int main() {
  int n, S[100000], q, key, C = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%d", &S[i]);
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d", &key);
    C += binarySearch(S, n, key);
  }
  printf("%d\\n", C);
  return 0;
}

int binarySearch(int A[], int n, int key) {
  int l = 0;
  int r = n;
  while (r > l) {
    int mid = (l + r) / 2;
    if (A[mid] == key)
      return true;
    if (A[mid] < key)
      l = mid + 1;
    if (A[mid] > key)
      r = mid;
  }
  return false;
}


#include <iostream>
#include <string>
using namespace std;
int main() {
  int n, q, count = 0;
  cin >> n;
  long long S[100001], T[50001];
  for (int i = 0; i < n; i++)
    cin >> S[i];
  cin >> q;
  bool x = false;
  for (int j = 0; j < q; j++)
    cin >> T[j];
  for (int j = 0; j < q; j++) {
    x = false;
    for (int i = 0; i < n; i++) {
      if (S[i] == T[j] && x == false) {
        count++;
        x = true;
      }
    }
  }
  cout << count << endl;
}

#include <iostream>
using namespace std;
int main() {
  int n, q, count = 0, middle, sup, inf, sp, ip, x;
  int S[100001];
  bool end;
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> S[i];
  cin >> q;
  for (int i = 0; i < q; i++) {
    sup = n - 1;
    inf = 0;
    end = false;
    cin >> x;
    while (!end) {
      middle = (sup + inf) / 2;
      sp = sup;
      ip = inf;
      if (n != 2 && inf == n - 2)
        middle = n - 1;
      if (x > S[middle])
        inf = middle;
      else if (x < S[middle])
        sup = middle;
      else if (x == S[middle]) {
        end = true;
        count++;
      }
      if (sp == sup && ip == inf)
        end = true;
    }
  }
  cout << count << endl;
}


#include <stdio.h>

bool FindByBinarySearch(int x, int A[], int left, int right) {
  int mid = (left + right) / 2;
  if (x == A[mid])
    return true;
  if (x >= A[left] && x < A[mid])
    return FindByBinarySearch(x, A, left, mid);
  if (x > A[mid] && x <= A[right])
    return FindByBinarySearch(x, A, mid + 1, right);

  return false;
}

int main() {
  int n, q, S[100000], T[50000];
  int C = 0;

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

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

  for (int i = 0; i < q; ++i) {
    for (int j = 0; j < n; ++j) {
      if (FindByBinarySearch(T[i], S, 0, n - 1)) {
        ++C;
        break;
      }
    }
  }

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

  return 0;
}

#include <stdio.h>

bool FindByBinarySearch(int x, int A[], int left, int right) {
  int mid = (left + right) / 2;
  if (x == A[mid])
    return true;
  if (x >= A[left] && x < A[mid])
    return FindByBinarySearch(x, A, left, mid);
  if (x > A[mid] && x <= A[right])
    return FindByBinarySearch(x, A, mid + 1, right);

  return false;
}

int main() {
  int n, q, S[100000], T[50000];
  int C = 0;

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

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

  for (int i = 0; i < q; ++i) {
    if (FindByBinarySearch(T[i], S, 0, n - 1)) {
      ++C;
    }
  }

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

  return 0;
}


#include <iostream>

using namespace std;

bool BSearch(int A[], unsigned int sp, unsigned int ep,
             int n) { // あり、なしのみboolで返す
  int mid = (ep - sp) / 2;
  if (mid == n)
    return 1;
  if (sp > ep)
    return 0;
  else if (n < mid)
    return BSearch(A, sp, mid - 1, n);
  else
    return BSearch(A, mid + 1, ep, n);
}

int main(void) {
  int n, q;
  int counter = 0;
  int S[100000];
  int T[50000];
  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 (int i = 0; i < n; i++) {
    if (BSearch(T, 0, q, S[i]) && S[i] != S[i - 1])
      counter++;
  }
  cout << counter << endl;
}

#include <iostream>

using namespace std;

bool BSearch(int A[], unsigned int sp, unsigned int ep,
             int n) { // あり、なしのみboolで返す
  int mid = (ep + sp) / 2;
  int l = sp;
  int r = ep;
  while (l <= r) {
    mid = (l + r) / 2;
    if (A[mid] == n) {
      return 1;
    } else if (A[mid] < n) {
      l = mid + 1;
    } else {
      r = mid - 1;
    }
  }
  return 0;
}

int main(void) {
  int n, q;
  int counter = 0;
  int S[100000];
  int T[50000];
  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 (int i = 0; i < q; i++) {
    if (BSearch(S, 0, n, T[i])) {
      counter++;
      // cout << T[i] << "is found!" << endl;
    } else {
      // cout << T[i] << "is not found" << endl;
    }
  }
  cout << counter << endl;
}


#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
int bisearch(vector<int> A, int a, int left, int right) {
  int mid = (left + right) / 2;
  if (A[mid] == a)
    return 1;
  else if (left == (right - 1)) {
    if (A[left] == a || A[right] == a)
      return 1;
    else
      return 0;
  } else
    return (bisearch(A, a, left, mid) || bisearch(A, a, mid, right));
}

int main() {
  int n, q, a, k = 0;
  cin >> n;
  vector<int> A;
  for (int i = 0; i < n; i++) {
    cin >> a;
    A.push_back(a);
  }
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> a;
    k += bisearch(A, a, 0, n - 1);
  }
  cout << k << endl;
  return 0;
}

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

int n;
vector<int> A;

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

int main() {
  int q, a, k = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    A.push_back(a);
  }
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> a;
    k += bisearch(a);
  }
  cout << k << endl;
  return 0;
}


#include <stdio.h>

int BinarySearch(int a[], int key, int start, int end) {
  int Start = start, End = end;
  int med;
  while (Start != End) {
    med = (Start + End) / 2;
    if (a[med] == key)
      return med;
    else if (a[med] < key)
      Start = med + 1;
    else
      End = med - 1;
  }
  if (a[Start] == key)
    return Start;
  return -1;
}

int main() {
  int n, q;
  int S[100000], T[50000];
  int cnt = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &S[i]);
  }
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d", &T[i]);
  }
  for (int j = 0; j < q; j++) {
    if (BinarySearch(S, T[j], 0, n - 1) != -1) {
      cnt++;
    }
  }
  printf("%d\\n", cnt);

  return 0;
}

#include <stdio.h>

int BinarySearch(int a[], int key, int start, int end) {
  int Start = start, End = end;
  int med;
  while (Start != End) {
    med = (Start + End) / 2;
    if (a[med] == key)
      return med;
    else if (a[med] < key)
      Start = med + 1;
    else
      End = med;
  }
  if (a[Start] == key)
    return Start;
  return -1;
}

int main() {
  int n, q;
  int S[100000], T[50000];
  int cnt = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &S[i]);
  }
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d", &T[i]);
  }
  for (int j = 0; j < q; j++) {
    if (BinarySearch(S, T[j], 0, n) != -1) {
      cnt++;
    }
  }
  printf("%d\\n", cnt);

  return 0;
}


#include <iostream>
using namespace std;

bool search(int S[], int n, int num) {
  int min = 0;
  int max = n - 1;
  int pos = n / 2;
  while (min < max) {
    if (S[pos] == num) {
      return true;
    }

    if (S[pos] > num) {
      max = pos;
      pos -= (min + pos) / 2 + (min + pos) % 2;
    } else {
      min = pos;
      pos += (max - pos) / 2 + (max - pos) % 2;
    }
  }
  return false;
}

int main() {

  int n, q;
  int S[100000];
  int T[50000];
  int 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 (int i = 0; i < q; i++) {
    if (search(S, n, T[i]))
      cnt++;
  }

  cout << cnt << endl;

  return 0;
}

#include <iostream>
using namespace std;

bool search(int S[], int n, int num) {
  int min = 0;
  int max = n;
  int pos = n / 2;
  while (max - min > 1) {
    if (S[pos] == num) {
      return true;
    }
    if (S[pos] > num) {
      max = pos;
      pos -= (min + pos) / 2 + (min + pos) % 2;
    } else {
      min = pos;
      pos += (max - pos) / 2 + (max - pos) % 2;
    }
  }
  return false;
}

int main() {

  int n, q;
  int S[100000];
  int T[50000];
  int 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 (int i = 0; i < q; i++) {
    if (search(S, n, T[i]))
      cnt++;
  }

  cout << cnt << endl;

  return 0;
}


#include <cstdio>

int binarysearch(int *A, int n, int key) {
  int left = 0, right = n, mid;
  while (left < right) {
    mid = (right + left) / 2;

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

int main() {
  int n;
  scanf("%d", &n);

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

  int q;
  scanf("%d", &q);

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

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

  return 0;
}

#include <cstdio>

int A[100000], n;

int binarysearch(int key) {
  int left = 0, right = n, mid;
  while (left < right) {
    mid = (right + left) / 2;

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

int main() {
  scanf("%d", &n);

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

  int q;
  scanf("%d", &q);

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

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

  return 0;
}


#include <stdio.h>
int n, q, i, j, cou, a, b, d, m;
bool w;
int main() {
  scanf("%d", &n);
  int s[n];
  for (j = 0; j < n; j++) {
    scanf("%d", &s[j]);
  }
  scanf("%d", &q);
  int t[q];
  for (i = 0; i < q; i++) {
    scanf("%d", &t[i]);
  }
  cou = 0;

  for (i = 0; i < q; i++) {
    a = n;
    b = 0;
    d = 0.5;
    w = true;
    while ((a - b) / 2 >= d && w == true) {
      m = (a + b) / 2;
      if (t[i] < s[m]) {
        a = m;
      } else if (t[i] > s[m]) {
        b = m;
      } else
        w = false;
    }
    if (s[m] == t[i])
      cou = cou + 1;
  }
  printf("%d", cou);
  return 0;
}

#include <stdio.h>
int n, q, i, j, cou, a, b, d, m;
bool w;
int main() {
  scanf("%d", &n);
  int s[n];
  for (j = 0; j < n; j++) {
    scanf("%d", &s[j]);
  }
  scanf("%d", &q);
  int t[q];
  for (i = 0; i < q; i++) {
    scanf("%d", &t[i]);
  }
  cou = 0;

  for (i = 0; i < q; i++) {
    a = n;
    b = 0;
    d = 1;
    w = true;
    while ((a - b) / 2 >= d && w == true) {
      m = (a + b) / 2;
      if (t[i] < s[m]) {
        a = m;
      } else if (t[i] > s[m]) {
        b = m;
      } else
        w = false;
    }
    if (s[m] == t[i] || s[a] == t[i])
      cou = cou + 1;
  }
  printf("%d\\n", cou);
  return 0;
}


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

int main() {
  int n, q, S[10000], T, res = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> S[i];
  }
  sort(S, S + n);
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> T;
    if (binary_search(S, S + n, T))
      res++;
  }
  cout << res << endl;
  return 0;
}

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

int main() {
  int n, q, S[100000], T, res = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> S[i];
  }
  sort(S, S + n);
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> T;
    if (binary_search(S, S + n, T))
      res++;
  }
  cout << res << endl;
  return 0;
}


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

template <const int U = 1 << 30> class vEB {

  struct node {
    int min, max;
    node *summary, **cluster;
    node() : min(U), max(-1), summary(nullptr), cluster(nullptr) {}
    ~node() {
      if (summary)
        delete summary;
      if (cluster)
        delete[] cluster;
    }
  } *root;

  int cnt;

private:
  int downsqrt(int u) const {
    assert(u != 0 && (u & (u - 1)) == 0 && u > 2);
    return 1 << (__builtin_ctz(u) >> 1);
  }

  int upsqrt(int u) const {
    assert(u != 0 && (u & (u - 1)) == 0 && u > 2);
    int ctz = __builtin_ctz(u);
    return 1 << ((ctz >> 1) + (ctz & 1));
  }

  int high(int x, int u) const { return x / downsqrt(u); }

  int low(int x, int u) const { return x % downsqrt(u); }

  int index(int x, int y, int u) const { return x * downsqrt(u) + y; }

  int minimum(node *v) const { return v ? v->min : U; }

  int maximum(node *v) const { return v ? v->max : -1; }

  bool member(node *v, int x, int u) const {
    if (!v)
      return false;
    if (v->min == x || v->max == x)
      return true;
    if (!v->cluster)
      return false;
    return member(v->cluster[high(x, u)], low(x, u), downsqrt(u));
  }

  node *new_node(int u) {
    node *v = new node();
    if (u > 2) {
      int sz = upsqrt(u);
      v->cluster = new node *[sz];
      for (int i = 0; i < sz; i++) {
        v->cluster[i] = nullptr;
      }
    }
    return v;
  }

  node *empty_insert(node *v, int x, int u) {
    if (!v)
      v = new_node(u);
    v->min = v->max = x;
    return v;
  }

  node *insert(node *v, int x, int u) {
    if (!v)
      v = new_node(u);
    if (v->min == U) {
      empty_insert(v, x, u);
      return v;
    }
    if (x < v->min)
      swap(x, v->min);
    if (u > 2) {
      if (minimum(v->cluster[high(x, u)]) == U) {
        v->summary = insert(v->summary, high(x, u), downsqrt(u));
        v->cluster[high(x, u)] =
            empty_insert(v->cluster[high(x, u)], low(x, u), downsqrt(u));
      } else {
        v->cluster[high(x, u)] =
            insert(v->cluster[high(x, u)], low(x, u), downsqrt(u));
      }
    }
    if (x > v->max)
      v->max = x;
    return v;
  }

  node *erase(node *v, int x, int u) {
    if (v->min == v->max) {
      v->min = U;
      v->max = -1;
      delete v;
      return nullptr;
    }
    if (u <= 2) {
      v->max = v->min = (x == 0);
      return v;
    }
    if (x == v->min) {
      int first_cluster = minimum(v->summary);
      v->min = x = index(first_cluster, minimum(v->cluster[first_cluster]), u);
    }
    v->cluster[high(x, u)] =
        erase(v->cluster[high(x, u)], low(x, u), downsqrt(u));
    if (minimum(v->cluster[high(x, u)]) == U) {
      v->summary = erase(v->summary, high(x, u), downsqrt(u));
      if (x == v->max) {
        int summary_max = maximum(v->summary);
        if (summary_max == -1) {
          v->max = v->min;
        } else {
          v->max = index(summary_max, maximum(v->cluster[summary_max]), u);
        }
      }
    } else if (x == v->max) {
      v->max = index(high(x, u), maximum(v->cluster[high(x, u)]), u);
    }
    return v;
  }

  int successor(node *v, int x, int u) const {
    if (u <= 2) {
      if (x == 0 && v->max == 1)
        return 1;
      return U;
    }
    if (v->min != U && x < v->min)
      return v->min;
    int max_low = maximum(v->cluster[high(x, u)]);
    if (max_low != -1 && low(x, u) < max_low) {
      return index(high(x, u),
                   successor(v->cluster[high(x, u)], low(x, u), downsqrt(u)),
                   u);
    }
    int succ_cluster = successor(v->summary, high(x, u), downsqrt(u));
    if (succ_cluster == U)
      return U;
    return index(succ_cluster, minimum(v->cluster[succ_cluster]), u);
  }

  int predecessor(node *v, int x, int u) const {
    if (u <= 2) {
      if (x == 1 && v->min == 0)
        return 0;
      return -1;
    }
    if (v->max != -1 && x > v->max)
      return v->max;
    int min_low = minimum(v->cluster[high(x, u)]);
    if (min_low != U && low(x, u) > min_low) {
      return index(high(x, u),
                   predecessor(v->cluster[high(x, u)], low(x, u), downsqrt(u)),
                   u);
    }
    int pred_cluster = predecessor(v->summary, high(x, u), downsqrt(u));
    if (pred_cluster == -1) {
      if (v->min != -1 && x > v->min)
        return v->min;
      return -1;
    }
    return index(pred_cluster, maximum(v->cluster[pred_cluster]), u);
  }

public:
  vEB() : root(nullptr), cnt(0) {}

  ~vEB() {
    if (root)
      delete root;
  }

  int size() const { return cnt; }

  bool member(int x) const { return member(root, x, U); }

  int minimum() const { return minimum(root); }

  int maximum() const { return maximum(root); }

  void insert(int x) {
    if (!member(x))
      root = insert(root, x, U), cnt++;
  }

  void erase(int x) {
    if (member(x))
      root = erase(root, x, U), cnt--;
  }

  int successor(int x) const { return successor(root, x, U); }

  int predecessor(int x) const { return predecessor(root, x, U); }
};

int main() {
  int n, q;
  cin >> n;
  vEB<> veb;
  for (int i = 0; i < n; i++) {
    int si;
    cin >> si;
    veb.insert(si);
  }
  int res = 0;
  cin >> q;
  for (int j = 0; j < q; j++) {
    int ti;
    cin >> ti;
    res += veb.member(ti);
  }
  cout << res << endl;
  return 0;
}

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

template <const int U = 1 << 30> class vEB {

  struct node {
    int min, max;
    node *summary, **cluster;
    node() : min(U), max(-1), summary(nullptr), cluster(nullptr) {}
    ~node() {
      if (summary)
        delete summary;
      if (cluster)
        delete[] cluster;
    }
  } *root;

  int cnt;

private:
  int downsqrt(int u) const {
    assert(u != 0 && (u & (u - 1)) == 0 && u > 2);
    return 1 << (__builtin_ctz(u) >> 1);
  }

  int upsqrt(int u) {
    assert(u != 0 && (u & (u - 1)) == 0 && u > 2);
    int ctz = __builtin_ctz(u);
    return 1 << ((ctz >> 1) + (ctz & 1));
  }

  int high(int x, int u) const { return x / downsqrt(u); }

  int low(int x, int u) const { return x % downsqrt(u); }

  int index(int x, int y, int u) const { return x * downsqrt(u) + y; }

  int minimum(node *v) const { return v ? v->min : U; }

  int maximum(node *v) const { return v ? v->max : -1; }

  bool member(node *v, int x, int u) const {
    if (!v)
      return false;
    if (v->min == x || v->max == x)
      return true;
    if (!v->cluster)
      return false;
    return member(v->cluster[high(x, u)], low(x, u), downsqrt(u));
  }

  node *new_node(int u) {
    node *v = new node();
    if (u > 2) {
      int sz = upsqrt(u);
      v->cluster = new node *[sz];
      for (int i = 0; i < sz; i++) {
        v->cluster[i] = nullptr;
      }
    }
    return v;
  }

  node *empty_insert(node *v, int x, int u) {
    if (!v)
      v = new_node(u);
    v->min = v->max = x;
    return v;
  }

  node *insert(node *v, int x, int u) {
    if (!v)
      v = new_node(u);
    if (v->min == U) {
      empty_insert(v, x, u);
      return v;
    }
    if (x < v->min)
      swap(x, v->min);
    if (u > 2) {
      if (minimum(v->cluster[high(x, u)]) == U) {
        v->summary = insert(v->summary, high(x, u), upsqrt(u));
        v->cluster[high(x, u)] =
            empty_insert(v->cluster[high(x, u)], low(x, u), downsqrt(u));
      } else {
        v->cluster[high(x, u)] =
            insert(v->cluster[high(x, u)], low(x, u), downsqrt(u));
      }
    }
    if (x > v->max)
      v->max = x;
    return v;
  }

  node *erase(node *v, int x, int u) {
    if (v->min == v->max) {
      v->min = U;
      v->max = -1;
      delete v;
      return nullptr;
    }
    if (u <= 2) {
      v->max = v->min = (x == 0);
      return v;
    }
    if (x == v->min) {
      int first_cluster = minimum(v->summary);
      v->min = x = index(first_cluster, minimum(v->cluster[first_cluster]), u);
    }
    v->cluster[high(x, u)] =
        erase(v->cluster[high(x, u)], low(x, u), downsqrt(u));
    if (minimum(v->cluster[high(x, u)]) == U) {
      v->summary = erase(v->summary, high(x, u), upsqrt(u));
      if (x == v->max) {
        int summary_max = maximum(v->summary);
        if (summary_max == -1) {
          v->max = v->min;
        } else {
          v->max = index(summary_max, maximum(v->cluster[summary_max]), u);
        }
      }
    } else if (x == v->max) {
      v->max = index(high(x, u), maximum(v->cluster[high(x, u)]), u);
    }
    return v;
  }

  int successor(node *v, int x, int u) const {
    if (u <= 2) {
      if (x == 0 && v->max == 1)
        return 1;
      return U;
    }
    if (v->min != U && x < v->min)
      return v->min;
    int max_low = maximum(v->cluster[high(x, u)]);
    if (max_low != -1 && low(x, u) < max_low) {
      return index(high(x, u),
                   successor(v->cluster[high(x, u)], low(x, u), downsqrt(u)),
                   u);
    }
    int succ_cluster = successor(v->summary, high(x, u), upsqrt(u));
    if (succ_cluster == U)
      return U;
    return index(succ_cluster, minimum(v->cluster[succ_cluster]), u);
  }

  int predecessor(node *v, int x, int u) const {
    if (u <= 2) {
      if (x == 1 && v->min == 0)
        return 0;
      return -1;
    }
    if (v->max != -1 && x > v->max)
      return v->max;
    int min_low = minimum(v->cluster[high(x, u)]);
    if (min_low != U && low(x, u) > min_low) {
      return index(high(x, u),
                   predecessor(v->cluster[high(x, u)], low(x, u), downsqrt(u)),
                   u);
    }
    int pred_cluster = predecessor(v->summary, high(x, u), upsqrt(u));
    if (pred_cluster == -1) {
      if (v->min != -1 && x > v->min)
        return v->min;
      return -1;
    }
    return index(pred_cluster, maximum(v->cluster[pred_cluster]), u);
  }

public:
  vEB() : root(nullptr), cnt(0) {}

  ~vEB() {
    if (root)
      delete root;
  }

  int size() const { return cnt; }

  bool member(int x) const { return member(root, x, U); }

  int minimum() const { return minimum(root); }

  int maximum() const { return maximum(root); }

  void insert(int x) {
    if (!member(x))
      root = insert(root, x, U), cnt++;
  }

  void erase(int x) {
    if (member(x))
      root = erase(root, x, U), cnt--;
  }

  int successor(int x) const { return successor(root, x, U); }

  int predecessor(int x) const { return predecessor(root, x, U); }
};

int main() {
  int n, q;
  cin >> n;
  vEB<> veb;
  for (int i = 0; i < n; i++) {
    int si;
    cin >> si;
    veb.insert(si);
  }
  int res = 0;
  cin >> q;
  for (int j = 0; j < q; j++) {
    int ti;
    cin >> ti;
    res += veb.member(ti);
  }
  cout << res << endl;
  return 0;
}


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

template <const int U = 1 << 30> class vEB {

  struct node {
    int min, max;
    node *summary, **cluster;
    node() : min(U), max(-1), summary(nullptr), cluster(nullptr) {}
  } *root;

  int cnt;

private:
  int downsqrt(int ub) const { return ub >> 1; }

  int upsqrt(int ub) { return (ub >> 1) + (ub & 1); }

  int high(int x, int ub) const { return x >> ub; }

  int low(int x, int ub) const { return x & ((1 << ub) - 1); }

  int index(int x, int y, int ub) const { return (x << downsqrt(ub)) + y; }

  int minimum(node *v) const { return v ? v->min : U; }

  int maximum(node *v) const { return v ? v->max : -1; }

  bool member(node *v, int x, int ub) const {
    if (!v)
      return false;
    if (v->min == x || v->max == x)
      return true;
    if (!v->cluster)
      return false;
    return member(v->cluster[high(x, ub)], low(x, ub), downsqrt(ub));
  }

  node *new_node(int ub) {
    node *v = new node();
    if (ub > 1) {
      int sz = 1 << upsqrt(ub);
      v->cluster = new node *[sz];
      for (int i = 0; i < sz; i++) {
        v->cluster[i] = nullptr;
      }
    }
    return v;
  }

  node *empty_insert(node *v, int x, int ub) {
    if (!v)
      v = new_node(ub);
    v->min = v->max = x;
    return v;
  }

  node *insert(node *v, int x, int ub) {
    if (!v)
      v = new_node(ub);
    if (v->min == U) {
      empty_insert(v, x, ub);
      return v;
    }
    if (x < v->min)
      swap(x, v->min);
    if (ub > 1) {
      if (minimum(v->cluster[high(x, ub)]) == U) {
        v->summary = insert(v->summary, high(x, ub), upsqrt(ub));
        v->cluster[high(x, ub)] =
            empty_insert(v->cluster[high(x, ub)], low(x, ub), downsqrt(ub));
      } else {
        v->cluster[high(x, ub)] =
            insert(v->cluster[high(x, ub)], low(x, ub), downsqrt(ub));
      }
    }
    if (x > v->max)
      v->max = x;
    return v;
  }

  node *erase(node *v, int x, int ub) {
    if (v->min == v->max) {
      v->min = U;
      v->max = -1;
      return nullptr;
    }
    if (ub <= 1) {
      v->max = v->min = (x == 0);
      return v;
    }
    if (x == v->min) {
      int first_cluster = minimum(v->summary);
      v->min = x = index(first_cluster, minimum(v->cluster[first_cluster]), ub);
    }
    v->cluster[high(x, ub)] =
        erase(v->cluster[high(x, ub)], low(x, ub), downsqrt(ub));
    if (minimum(v->cluster[high(x, ub)]) == U) {
      v->summary = erase(v->summary, high(x, ub), upsqrt(ub));
      if (x == v->max) {
        int summary_max = maximum(v->summary);
        if (summary_max == -1) {
          v->max = v->min;
        } else {
          v->max = index(summary_max, maximum(v->cluster[summary_max]), ub);
        }
      }
    } else if (x == v->max) {
      v->max = index(high(x, ub), maximum(v->cluster[high(x, ub)]), ub);
    }
    return v;
  }

  int successor(node *v, int x, int ub) const {
    if (ub <= 1) {
      if (x == 0 && v->max == 1)
        return 1;
      return U;
    }
    if (v->min != U && x < v->min)
      return v->min;
    int max_low = maximum(v->cluster[high(x, ub)]);
    if (max_low != -1 && low(x, ub) < max_low) {
      return index(high(x, ub),
                   successor(v->cluster[high(x, ub)], low(x, ub), downsqrt(ub)),
                   ub);
    }
    int succ_cluster = successor(v->summary, high(x, ub), upsqrt(ub));
    if (succ_cluster == U)
      return U;
    return index(succ_cluster, minimum(v->cluster[succ_cluster]), ub);
  }

  int predecessor(node *v, int x, int ub) const {
    if (ub <= 1) {
      if (x == 1 && v->min == 0)
        return 0;
      return -1;
    }
    if (v->max != -1 && x > v->max)
      return v->max;
    int min_low = minimum(v->cluster[high(x, ub)]);
    if (min_low != U && low(x, ub) > min_low) {
      return index(
          high(x, ub),
          predecessor(v->cluster[high(x, ub)], low(x, ub), downsqrt(ub)), ub);
    }
    int pred_cluster = predecessor(v->summary, high(x, ub), upsqrt(ub));
    if (pred_cluster == -1) {
      if (v->min != -1 && x > v->min)
        return v->min;
      return -1;
    }
    return index(pred_cluster, maximum(v->cluster[pred_cluster]), ub);
  }

public:
  vEB() : root(nullptr), cnt(0) {}

  int size() const { return cnt; }

  bool member(int x) const { return member(root, x, __builtin_ctz(U)); }

  int minimum() const { return minimum(root); }

  int maximum() const { return maximum(root); }

  void insert(int x) {
    if (!member(x))
      root = insert(root, x, __builtin_ctz(U)), cnt++;
  }

  void erase(int x) {
    if (member(x))
      root = erase(root, x, __builtin_ctz(U)), cnt--;
  }

  int successor(int x) const { return successor(root, x, __builtin_ctz(U)); }

  int predecessor(int x) const {
    return predecessor(root, x, __builtin_ctz(U));
  }
};

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n, q;
  cin >> n;
  vEB<> veb;
  for (int i = 0; i < n; i++) {
    int si;
    cin >> si;
    veb.insert(si);
  }
  int res = 0;
  cin >> q;
  for (int j = 0; j < q; j++) {
    int ti;
    cin >> ti;
    res += veb.member(ti);
  }
  cout << res << endl;
  return 0;
}

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

template <const int U = 1 << 30> class vEB {

  struct node {
    int min, max;
    node *summary, **cluster;
    node() : min(U), max(-1), summary(nullptr), cluster(nullptr) {}
  } *root;

  int cnt;

private:
  int downsqrt(int ub) const { return ub >> 1; }

  int upsqrt(int ub) { return (ub >> 1) + (ub & 1); }

  int high(int x, int ub) const { return x >> downsqrt(ub); }

  int low(int x, int ub) const { return x & ((1 << downsqrt(ub)) - 1); }

  int index(int x, int y, int ub) const { return (x << downsqrt(ub)) + y; }

  int minimum(node *v) const { return v ? v->min : U; }

  int maximum(node *v) const { return v ? v->max : -1; }

  bool member(node *v, int x, int ub) const {
    if (!v)
      return false;
    if (v->min == x || v->max == x)
      return true;
    if (!v->cluster)
      return false;
    return member(v->cluster[high(x, ub)], low(x, ub), downsqrt(ub));
  }

  node *new_node(int ub) {
    node *v = new node();
    if (ub > 1) {
      int sz = 1 << upsqrt(ub);
      v->cluster = new node *[sz];
      for (int i = 0; i < sz; i++) {
        v->cluster[i] = nullptr;
      }
    }
    return v;
  }

  node *empty_insert(node *v, int x, int ub) {
    if (!v)
      v = new_node(ub);
    v->min = v->max = x;
    return v;
  }

  node *insert(node *v, int x, int ub) {
    if (!v)
      v = new_node(ub);
    if (v->min == U) {
      empty_insert(v, x, ub);
      return v;
    }
    if (x < v->min)
      swap(x, v->min);
    if (ub > 1) {
      if (minimum(v->cluster[high(x, ub)]) == U) {
        v->summary = insert(v->summary, high(x, ub), upsqrt(ub));
        v->cluster[high(x, ub)] =
            empty_insert(v->cluster[high(x, ub)], low(x, ub), downsqrt(ub));
      } else {
        v->cluster[high(x, ub)] =
            insert(v->cluster[high(x, ub)], low(x, ub), downsqrt(ub));
      }
    }
    if (x > v->max)
      v->max = x;
    return v;
  }

  node *erase(node *v, int x, int ub) {
    if (v->min == v->max) {
      v->min = U;
      v->max = -1;
      return nullptr;
    }
    if (ub <= 1) {
      v->max = v->min = (x == 0);
      return v;
    }
    if (x == v->min) {
      int first_cluster = minimum(v->summary);
      v->min = x = index(first_cluster, minimum(v->cluster[first_cluster]), ub);
    }
    v->cluster[high(x, ub)] =
        erase(v->cluster[high(x, ub)], low(x, ub), downsqrt(ub));
    if (minimum(v->cluster[high(x, ub)]) == U) {
      v->summary = erase(v->summary, high(x, ub), upsqrt(ub));
      if (x == v->max) {
        int summary_max = maximum(v->summary);
        if (summary_max == -1) {
          v->max = v->min;
        } else {
          v->max = index(summary_max, maximum(v->cluster[summary_max]), ub);
        }
      }
    } else if (x == v->max) {
      v->max = index(high(x, ub), maximum(v->cluster[high(x, ub)]), ub);
    }
    return v;
  }

  int successor(node *v, int x, int ub) const {
    if (ub <= 1) {
      if (x == 0 && v->max == 1)
        return 1;
      return U;
    }
    if (v->min != U && x < v->min)
      return v->min;
    int max_low = maximum(v->cluster[high(x, ub)]);
    if (max_low != -1 && low(x, ub) < max_low) {
      return index(high(x, ub),
                   successor(v->cluster[high(x, ub)], low(x, ub), downsqrt(ub)),
                   ub);
    }
    int succ_cluster = successor(v->summary, high(x, ub), upsqrt(ub));
    if (succ_cluster == U)
      return U;
    return index(succ_cluster, minimum(v->cluster[succ_cluster]), ub);
  }

  int predecessor(node *v, int x, int ub) const {
    if (ub <= 1) {
      if (x == 1 && v->min == 0)
        return 0;
      return -1;
    }
    if (v->max != -1 && x > v->max)
      return v->max;
    int min_low = minimum(v->cluster[high(x, ub)]);
    if (min_low != U && low(x, ub) > min_low) {
      return index(
          high(x, ub),
          predecessor(v->cluster[high(x, ub)], low(x, ub), downsqrt(ub)), ub);
    }
    int pred_cluster = predecessor(v->summary, high(x, ub), upsqrt(ub));
    if (pred_cluster == -1) {
      if (v->min != -1 && x > v->min)
        return v->min;
      return -1;
    }
    return index(pred_cluster, maximum(v->cluster[pred_cluster]), ub);
  }

public:
  vEB() : root(nullptr), cnt(0) {}

  int size() const { return cnt; }

  bool member(int x) const { return member(root, x, __builtin_ctz(U)); }

  int minimum() const { return minimum(root); }

  int maximum() const { return maximum(root); }

  void insert(int x) {
    if (!member(x))
      root = insert(root, x, __builtin_ctz(U)), cnt++;
  }

  void erase(int x) {
    if (member(x))
      root = erase(root, x, __builtin_ctz(U)), cnt--;
  }

  int successor(int x) const { return successor(root, x, __builtin_ctz(U)); }

  int predecessor(int x) const {
    return predecessor(root, x, __builtin_ctz(U));
  }
};

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n, q;
  cin >> n;
  vEB<> veb;
  for (int i = 0; i < n; i++) {
    int si;
    cin >> si;
    veb.insert(si);
  }
  int res = 0;
  cin >> q;
  for (int j = 0; j < q; j++) {
    int ti;
    cin >> ti;
    res += veb.member(ti);
  }
  cout << res << endl;
  return 0;
}


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

template <typename T = int, const T U = (T)1 << (T)30> class vEB {
  const T ctz;
  struct node {
    T min, max;
    node *summary, **cluster;
    node() : min(U), max(-1), summary(nullptr), cluster(nullptr) {}
  } *root;
  int cnt;

private:
  T downsqrt(T ub) const { return ub >> (T)1; }
  T upsqrt(T ub) const { return (ub + 1) >> (T)1; }
  T high(T x, T ub) const { return x >> downsqrt(ub); }
  T low(T x, T ub) const { return x & (((T)1 << downsqrt(ub)) - 1); }
  T index(T x, T y, T ub) const { return (x << downsqrt(ub)) + y; }
  T minimum(node *v) const { return v ? v->min : U; }
  T maximum(node *v) const { return v ? v->max : -1; }
  bool member(node *v, T x, T ub) const {
    if (!v)
      return false;
    if (v->min == x || v->max == x)
      return true;
    if (!v->cluster)
      return false;
    return member(v->cluster[high(x, ub)], low(x, ub), downsqrt(ub));
  }
  node *new_node(T ub) {
    node *v = new node();
    if (ub > 1) {
      T sz = (T)1 << upsqrt(ub);
      v->cluster = new node *[sz];
      for (int i = 0; i < sz; i++) {
        v->cluster[i] = nullptr;
      }
    }
    return v;
  }
  node *empty_insert(node *v, T x, T ub) {
    if (!v)
      v = new_node(ub);
    v->min = v->max = x;
    return v;
  }
  node *insert(node *v, T x, T ub) {
    if (!v)
      v = new_node(ub);
    if (v->min == U) {
      empty_insert(v, x, ub);
      return v;
    }
    if (x < v->min)
      swap(x, v->min);
    if (ub > 1) {
      if (minimum(v->cluster[high(x, ub)]) == U) {
        v->summary = insert(v->summary, high(x, ub), upsqrt(ub));
        v->cluster[high(x, ub)] =
            empty_insert(v->cluster[high(x, ub)], low(x, ub), downsqrt(ub));
      } else {
        v->cluster[high(x, ub)] =
            insert(v->cluster[high(x, ub)], low(x, ub), downsqrt(ub));
      }
    }
    if (x > v->max)
      v->max = x;
    return v;
  }
  node *erase(node *v, T x, T ub) {
    if (v->min == v->max) {
      v->min = U;
      v->max = -1;
      return nullptr;
    }
    if (ub <= 1) {
      v->max = v->min = (x == 0);
      return v;
    }
    if (x == v->min) {
      T first_cluster = minimum(v->summary);
      v->min = x = index(first_cluster, minimum(v->cluster[first_cluster]), ub);
    }
    v->cluster[high(x, ub)] =
        erase(v->cluster[high(x, ub)], low(x, ub), downsqrt(ub));
    if (minimum(v->cluster[high(x, ub)]) == U) {
      v->summary = erase(v->summary, high(x, ub), upsqrt(ub));
      if (x == v->max) {
        T summary_max = maximum(v->summary);
        if (summary_max == -1) {
          v->max = v->min;
        } else {
          v->max = index(summary_max, maximum(v->cluster[summary_max]), ub);
        }
      }
    } else if (x == v->max) {
      v->max = index(high(x, ub), maximum(v->cluster[high(x, ub)]), ub);
    }
    return v;
  }
  T successor(node *v, T x, T ub) const {
    if (!v)
      return U;
    if (ub <= 1) {
      if (x == 0 && v->max == 1)
        return 1;
      return U;
    }
    if (v->min != U && x < v->min)
      return v->min;
    T max_low = maximum(v->cluster[high(x, ub)]);
    if (max_low != -1 && low(x, ub) < max_low) {
      return index(high(x, ub),
                   successor(v->cluster[high(x, ub)], low(x, ub), downsqrt(ub)),
                   ub);
    }
    T succ_cluster = successor(v->summary, high(x, ub), upsqrt(ub));
    if (succ_cluster == U)
      return U;
    return index(succ_cluster, minimum(v->cluster[succ_cluster]), ub);
  }
  T predecessor(node *v, T x, T ub) const {
    if (!v)
      return -1;
    if (ub <= 1) {
      if (x == 1 && v->min == 0)
        return 0;
      return -1;
    }
    if (v->max != -1 && x > v->max)
      return v->max;
    T min_low = minimum(v->cluster[high(x, ub)]);
    if (min_low != U && low(x, ub) > min_low) {
      return index(
          high(x, ub),
          predecessor(v->cluster[high(x, ub)], low(x, ub), downsqrt(ub)), ub);
    }
    T pred_cluster = predecessor(v->summary, high(x, ub), upsqrt(ub));
    if (pred_cluster == -1) {
      if (v->min != U && x > v->min)
        return v->min;
      return -1;
    }
    return index(pred_cluster, maximum(v->cluster[pred_cluster]), ub);
  }
  T get_ctz(T x) {
    T tmp = 1, res = 0;
    while (tmp < x) {
      tmp <<= (T)1;
      res++;
    }
    return res;
  }

public:
  vEB() : ctz(get_ctz(U)), root(nullptr), cnt(0) {}
  int size() const { return cnt; }
  bool member(T x) const { return member(root, x, ctz); }
  T minimum() const { return minimum(root); }
  T maximum() const { return maximum(root); }
  void insert(T x) {
    if (!member(x))
      root = insert(root, x, ctz), cnt++;
  }
  void erase(T x) {
    if (member(x))
      root = erase(root, x, ctz), cnt--;
  }
  T successor(T x) const { return successor(root, x, ctz); }
  T predecessor(T x) const { return predecessor(root, x, ctz); }
};

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n;
  cin >> n;
  vEB<ll, 1ll << 50ll> veb;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    veb.insert(x);
  }
  int q, res = 0;
  cin >> q;
  while (q--) {
    int x;
    cin >> x;
    res += veb.member(x);
  }
  cout << res << endl;
  return 0;
}

#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
using ll = long long;

template <typename T = int, const T U = (T)1 << (T)30> class vEB {
  const T ctz;
  struct node {
    T min, max;
    node *summary;
    unordered_map<T, node *> cluster;
    node() : min(U), max(-1), summary(nullptr) {}
  } *root;
  int cnt;

private:
  T downsqrt(T ub) const { return ub >> (T)1; }
  T upsqrt(T ub) const { return (ub + 1) >> (T)1; }
  T high(T x, T ub) const { return x >> downsqrt(ub); }
  T low(T x, T ub) const { return x & (((T)1 << downsqrt(ub)) - 1); }
  T index(T x, T y, T ub) const { return (x << downsqrt(ub)) + y; }
  T minimum(node *v) const { return v ? v->min : U; }
  T maximum(node *v) const { return v ? v->max : -1; }
  bool member(node *v, T x, T ub) const {
    if (!v)
      return false;
    if (v->min == x || v->max == x)
      return true;
    if (v->cluster.empty())
      return false;
    return member(v->cluster[high(x, ub)], low(x, ub), downsqrt(ub));
  }
  node *empty_insert(node *v, T x, T ub) {
    if (!v)
      v = new node();
    v->min = v->max = x;
    return v;
  }
  node *insert(node *v, T x, T ub) {
    if (!v)
      v = new node();
    if (v->min == U) {
      empty_insert(v, x, ub);
      return v;
    }
    if (x < v->min)
      swap(x, v->min);
    if (ub > 1) {
      if (minimum(v->cluster[high(x, ub)]) == U) {
        v->summary = insert(v->summary, high(x, ub), upsqrt(ub));
        v->cluster[high(x, ub)] =
            empty_insert(v->cluster[high(x, ub)], low(x, ub), downsqrt(ub));
      } else {
        v->cluster[high(x, ub)] =
            insert(v->cluster[high(x, ub)], low(x, ub), downsqrt(ub));
      }
    }
    if (x > v->max)
      v->max = x;
    return v;
  }
  node *erase(node *v, T x, T ub) {
    if (v->min == v->max) {
      v->min = U;
      v->max = -1;
      return nullptr;
    }
    if (ub <= 1) {
      v->max = v->min = (x == 0);
      return v;
    }
    if (x == v->min) {
      T first_cluster = minimum(v->summary);
      v->min = x = index(first_cluster, minimum(v->cluster[first_cluster]), ub);
    }
    v->cluster[high(x, ub)] =
        erase(v->cluster[high(x, ub)], low(x, ub), downsqrt(ub));
    if (minimum(v->cluster[high(x, ub)]) == U) {
      v->summary = erase(v->summary, high(x, ub), upsqrt(ub));
      if (x == v->max) {
        T summary_max = maximum(v->summary);
        if (summary_max == -1) {
          v->max = v->min;
        } else {
          v->max = index(summary_max, maximum(v->cluster[summary_max]), ub);
        }
      }
    } else if (x == v->max) {
      v->max = index(high(x, ub), maximum(v->cluster[high(x, ub)]), ub);
    }
    return v;
  }
  T successor(node *v, T x, T ub) const {
    if (!v)
      return U;
    if (ub <= 1) {
      if (x == 0 && v->max == 1)
        return 1;
      return U;
    }
    if (v->min != U && x < v->min)
      return v->min;
    T max_low = maximum(v->cluster[high(x, ub)]);
    if (max_low != -1 && low(x, ub) < max_low) {
      return index(high(x, ub),
                   successor(v->cluster[high(x, ub)], low(x, ub), downsqrt(ub)),
                   ub);
    }
    T succ_cluster = successor(v->summary, high(x, ub), upsqrt(ub));
    if (succ_cluster == U)
      return U;
    return index(succ_cluster, minimum(v->cluster[succ_cluster]), ub);
  }
  T predecessor(node *v, T x, T ub) const {
    if (!v)
      return -1;
    if (ub <= 1) {
      if (x == 1 && v->min == 0)
        return 0;
      return -1;
    }
    if (v->max != -1 && x > v->max)
      return v->max;
    T min_low = minimum(v->cluster[high(x, ub)]);
    if (min_low != U && low(x, ub) > min_low) {
      return index(
          high(x, ub),
          predecessor(v->cluster[high(x, ub)], low(x, ub), downsqrt(ub)), ub);
    }
    T pred_cluster = predecessor(v->summary, high(x, ub), upsqrt(ub));
    if (pred_cluster == -1) {
      if (v->min != U && x > v->min)
        return v->min;
      return -1;
    }
    return index(pred_cluster, maximum(v->cluster[pred_cluster]), ub);
  }
  T get_ctz(T x) {
    T tmp = 1, res = 0;
    while (tmp < x) {
      tmp <<= (T)1;
      res++;
    }
    return res;
  }

public:
  vEB() : ctz(get_ctz(U)), root(nullptr), cnt(0) {}
  int size() const { return cnt; }
  bool member(T x) const { return member(root, x, ctz); }
  T minimum() const { return minimum(root); }
  T maximum() const { return maximum(root); }
  void insert(T x) {
    if (!member(x))
      root = insert(root, x, ctz), cnt++;
  }
  void erase(T x) {
    if (member(x))
      root = erase(root, x, ctz), cnt--;
  }
  T successor(T x) const { return successor(root, x, ctz); }
  T predecessor(T x) const { return predecessor(root, x, ctz); }
};

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n;
  cin >> n;
  vEB<ll, 1ll << 62ll> veb;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    veb.insert(x);
  }
  int q, res = 0;
  cin >> q;
  while (q--) {
    int x;
    cin >> x;
    res += veb.member(x);
  }
  cout << res << endl;
  return 0;
}


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

int binary_search(int start, int end, long int *s, int key) {
  // cout << "binary_search with " << start << " " << end << " " << key << endl;
  int match = 0;
  if (start != end) {
    int x;
    x = start + floor((end - start) / 2);
    if (s[x] == key) {
      match = 1;
    } else if (s[x] > key) {
      match = binary_search(start, x - 1, s, key);
    } else {
      match = binary_search(x + 1, end, s, key);
    }
  } else {
    if (s[start] == key)
      match = 1;
  }
  // cout << "return " << match << endl;
  return match;
}

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

  int count = 0;
  for (int i = 0; i < q; ++i) {
    count += binary_search(0, n - 1, s, t[i]);
    // cout << "count is " << count << endl;
  }

  cout << count << endl;
}

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

int binary_search(int start, int end, long int *s, int key) {
  // cout << "binary_search with " << start << " " << end << " " << key << endl;
  int match = 0;
  if (start != end) {
    int x;
    x = start + floor((end - start) / 2);
    if (s[x] == key) {
      match = 1;
    } else if (s[x] > key) {
      match = binary_search(start, max(x - 1, start), s, key);
    } else {
      match = binary_search(min(x + 1, end), end, s, key);
    }
  } else {
    if (s[start] == key)
      match = 1;
  }
  // cout << "return " << match << endl;
  return match;
}

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

  int count = 0;
  for (int i = 0; i < q; ++i) {
    count += binary_search(0, n - 1, s, t[i]);
    // cout << "count is " << count << endl;
  }

  cout << count << endl;
}


#include <bits/stdc++.h>
using namespace std;
int main() {

  int n;

  cin >> n;

  int a[101];

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

  int t, cnt = 0;
  cin >> t;

  int q;

  for (int i = 0; i < t; i++) {
    cin >> q;

    if (upper_bound(a, a + n, q) - lower_bound(a, a + n, q)) {
      cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main() {

  int n;

  cin >> n;

  int a[100001];

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

  int t, cnt = 0;
  cin >> t;

  int q;

  for (int i = 0; i < t; i++) {
    cin >> q;

    if (upper_bound(a, a + n, q) - lower_bound(a, a + n, q)) {
      cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}


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

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

  int n, q;
  int count = 0;
  cin >> n;
  int *S = new int[n + 1];
  for (int i = 0; i < n; i++) {
    cin >> S[i];
  }
  cin >> q;
  for (int i = 0; i < q; i++) {
    int left = 0;
    int right = q;
    int mid;
    while (left < right) {
      mid = (right - left) / 2;
      if (S[mid] == i) {
        count++;
        break;
      } else if (S[mid] < i) {
        right = mid;
      } else {
        left = mid + 1;
      }
    }
  }

  cout << count << endl;

  return 0;
}

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

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

  int n, q;
  int count = 0;
  cin >> n;
  int *S = new int[n];
  for (int i = 0; i < n; i++) {
    cin >> S[i];
  }
  cin >> q;
  int x;
  for (int i = 0; i < q; i++) {
    cin >> x;
    int left = 0;
    int right = n;
    int mid;
    while (left < right) {
      mid = (left + right) / 2;
      if (S[mid] == x) {
        count++;
        break;
      } else if (S[mid] < x) {
        left = mid + 1;
      } else {
        right = mid;
      }
    }
  }

  cout << count << endl;

  return 0;
}


#include <iostream>
#include <vector>

using namespace std;

bool find(const vector<int> &S, int begin, int end, int x) {
  if (end - begin <= 0) {
    return false;
  }
  int mid = (begin + end) / 2;
  if (x < S[mid]) {
    return find(S, begin, mid, x);
  } else if (S[mid] < x) {
    return find(S, mid, end, x);
  } else {
    return true;
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  vector<int> S(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];
  }

  int count = 0;
  for (int i = 0; i < q; ++i) {
    if (find(S, 0, S.size(), T[i])) {
      ++count;
    }
  }
  cout << count << endl;
}

#include <iostream>
#include <vector>

using namespace std;

bool find(const vector<int> &S, int begin, int end, int x) {
  if (end - begin == 1) {
    return S[begin] == x;
  }
  int mid = (begin + end) / 2;
  if (x < S[mid]) {
    return find(S, begin, mid, x);
  } else if (S[mid] < x) {
    return find(S, mid, end, x);
  } else {
    return true;
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  vector<int> S(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];
  }

  int count = 0;
  for (int i = 0; i < q; ++i) {
    if (find(S, 0, S.size(), T[i])) {
      ++count;
    }
  }
  cout << count << endl;
}


#include <iostream>
using namespace std;

bool Linear(int x, int s[], int n) {
  for (int i = 0; i < n; i++) {
    if (s[i] == x)
      return true;
  }

  return false;
}

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

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

  int q;
  cin >> q;

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

  int count = 0;
  for (int i = 0; i < q; i++) {
    if (Linear(t[i], s, n) != 0) {
      count++;
    }
  }

  cout << count << endl;

  return 0;
}

#include <iostream>
using namespace std;

bool Binary(int x, int s[], int n) {
  int b = 0;
  int t = n - 1;

  while (b <= t) {
    int mid = (b + t) / 2;

    if (s[mid] == x) {
      return true;
    } else if (s[mid] < x) {
      b = mid + 1;
    } else {
      t = mid - 1;
    }
  }

  return false;
}

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

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

  int q;
  cin >> q;

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

  int count = 0;
  for (int i = 0; i < q; i++) {
    if (Binary(t[i], s, n) != false) {
      count++;
    }
  }

  cout << count << endl;

  return 0;
}


#include <algorithm>
#include <iostream>
#include <iterator>
#include <vector>
using namespace std;
void print(std::vector<int> &values) {
  for (int x : values) {
    std::cout << x << " ";
  }
  std::cout << std::endl;
}
// Time Limit Exceeded 1.98s

bool binarySearch(int x, vector<int> list, int start, int end) {
  int pivot = (int)(start + end) / 2.0;
  int length = end - start;
  if (length == -1) {
    return false;
  } else if (length == 0) {
    if (x == list[pivot]) {
      return true;
    } else {
      return false;
    }
  } else {
    if (x == list[pivot]) {
      return true;
    } else if (x > list[pivot]) {
      return binarySearch(x, list, pivot + 1, end);
    } else {
      return binarySearch(x, list, start, pivot - 1);
    }
  }
}

/*
bool binarySearch()
{
  int left=0;
  int right=n;

  while(left<right){
    int mid=(int)(left+right)/2
      if(list[mid]==
      }
*/
int main() {
  int n, q;
  cin >> n;
  vector<int> s(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  cin >> q;
  // sort(s.begin(),s.end());

  vector<int> t(q);
  for (int i = 0; i < q; i++) {
    cin >> t[i];
  }
  int cnt = 0;
  for (int i = 0; i < q; i++) {
    if (binarySearch(t[i], s, 0, n - 1) == true) {
      // cout<<t[i]<<"=>true"<<endl;
      cnt++;
    } else {
      // cout<<t[i]<<"=>false"<<endl;
    }
    // cout<<cnt<<endl;
  }
  cout << cnt << endl;
  return 0;
}

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

bool binary(vector<int> v, int x) {
  int l, r, med;
  l = 0;
  r = v.size() - 1;
  while (l < r) {
    if (v[r] == x or v[l] == x)
      return true;
    med = (r + l) / 2;
    if (x > v[med])
      l = med + 1;
    else if (x < v[med])
      r = med - 1;
    else
      return true;
  }
  return false;
}

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

  // input
  cin >> n;
  s.resize(n);
  for (int i = 0; i < n; i++)
    cin >> s[i];
  cin >> q;
  t.resize(q);
  for (int i = 0; i < q; i++)
    cin >> t[i];

  // process
  for (int i = 0; i < q; i++)
    if (binary(s, t[i]))
      c++;
  cout << c << endl;
  return 0;
}


#include <iostream>
using namespace std;

int main() {
  int b, i, r = 0, n, m, a[100000];
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  cin >> m;
  for (int j = 0; j < m; j++) {
    cin >> b;
    for (int l = 0; l < i; l++) {
      if (a[l] == b) {
        r++;
        break;
      }
    }
  }
  cout << r << endl;
  return 0;
}

#include <iostream>
using namespace std;

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

int main() {
  int r = 0, n, m, a, A[100000];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> a;
    if (binarySearch(A, n, a))
      r++;
  }
  cout << r << endl;
}


#include <iostream>
using namespace std;

int linear(int a[], int key, int n);
int main() {
  int i, j, n, q, c = 0;
  int s[1000000], t[1000000];

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

  cin >> q;
  for (i = 0; i < q; i++)
    cin >> t[i];

  for (i = 0; i < q; i++) {
    c += linear(s, t[i], n);
  }
  cout << c << endl;
}
int linear(int a[], int key, int n) {
  int i = 0;
  a[n] = key;
  while (a[i] != key) {
    i++;
  }
  if (i >= n) {
    return 0;
  } else {
    return 1;
  }
}

#include <iostream>
using namespace std;

int linear(int a[], int key, int n);
int main() {
  int i, j, n, q, c = 0;
  int s[100000], t[100000];

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

  cin >> q;
  for (i = 0; i < q; i++)
    cin >> t[i];

  for (i = 0; i < q; i++) {
    c += linear(s, t[i], n);
  }
  cout << c << endl;
}
int linear(int a[], int key, int n) {
  int left = 0;
  int right = n;
  int mid;
  while (left < right) {
    mid = (left + right) / 2;
    if (a[mid] == key) {
      return 1;
    } else if (key < a[mid]) {
      right = mid;
    } else {
      left = mid + 1;
    }
  }
  return 0;
}


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

int main() {
  long n, q, C = 0;
  cin >> n;
  vector<long> S(n);
  for (long i = 0; i < n; i++)
    cin >> S[i];
  cin >> q;
  vector<long> T(q);
  for (long i = 0; i < q; i++)
    cin >> T[i];
  for (long i = 0; i < q; i++) {
    for (long j = 0; j < n; j++) {
      if (T[i] == S[j]) {
        C++;
        break;
      }
      if (T[i] < S[j]) {
        break;
      }
    }
  }
  cout << C << endl;
  return 0;
}

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

int main() {
  long n, q, C = 0;
  cin >> n;
  vector<long> S(n + 1, 0);
  for (long i = 0; i < n; i++)
    cin >> S[i];
  cin >> q;
  vector<long> T(q, 0);
  for (long i = 0; i < q; i++)
    cin >> T[i];
  for (long i = 0; i < q; i++) {
    long a = 0, b = n;
    while (a < b) {
      if (S[(a + b) / 2] > T[i]) {
        b = (a + b) / 2;
      } else if (S[(a + b) / 2] == T[i]) {
        C++;
        break;
      } else {
        a = (a + b) / 2 + 1;
      }
    }
  }
  cout << C << endl;
  return 0;
}


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

using namespace std;

namespace shamal {
template <typename F, typename IndexType, typename TargetType>
pair<bool, IndexType> lower_bound(F const &func, IndexType left,
                                  IndexType right, TargetType const &t) {
  while (left != right) {
    auto const mid = left + (right - left) / 2;
    auto const val = func(mid);
    if (val > t) {
      right = mid - 1;
    } else if (val < t) {
      left = mid + 1;
    } else {
      right = mid;
    }
  }
  return {func(left) == t, left};
}
}; // namespace shamal

int main(void) {
  int ns, nt;
  cin >> ns;
  vector<int> s(ns);
  for (int i = 0; i < ns; i++) {
    scanf("%d", &s[i]);
  }

  cin >> nt;
  vector<int> t(nt);
  for (int i = 0; i < nt; i++) {
    scanf("%d", &t[i]);
  }

  int r = 0;
  for (auto const &x : t) {
    if (shamal::lower_bound([&](int i) { return s[i]; }, 0, ns - 1, x).first)
      r++;
  }
  cout << r << endl;
}

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

using namespace std;

namespace shamal {
template <typename F, typename IndexType, typename TargetType>
pair<bool, IndexType> lower_bound(F const &func, IndexType left,
                                  IndexType right, TargetType const &t) {
  do {
    auto const mid = left + (right - left) / 2;
    auto const val = func(mid);
    if (val > t) {
      right = mid - 1;
    } else if (val < t) {
      left = mid + 1;
    } else {
      right = mid;
    }
  } while (left <= right);

  return {func(left) == t, left};
}
template <typename F, typename IndexType, typename TargetType>
pair<bool, IndexType> binary_search(F const &func, IndexType left,
                                    IndexType right, TargetType const &t) {
  do {
    auto const mid = left + (right - left) / 2;
    auto const val = func(mid);
    if (val > t) {
      right = mid - 1;
    } else if (val < t) {
      left = mid + 1;
    } else {
      return {true, mid};
    }
  } while (left <= right);
  return {false, IndexType()};
}
}; // namespace shamal

int main(void) {
  int ns, nt;
  cin >> ns;
  vector<int> s(ns);
  for (int i = 0; i < ns; i++) {
    scanf("%d", &s[i]);
  }

  cin >> nt;
  vector<int> t(nt);
  for (int i = 0; i < nt; i++) {
    scanf("%d", &t[i]);
  }

  int r = 0;
  for (auto const &x : t) {
    if (shamal::binary_search([&](int i) { return s[i]; }, 0, ns - 1, x).first)
      r++;
  }
  cout << r << endl;
}


#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;
}

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

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

  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    scanf("%d", &k);
    if (binarySearch(k))
      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;
}

int main(void) {
  int i, q, k, 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", &k);
    if (binarySearch(k))
      sum++;
  }
  printf("%d\\n", sum);
  return 0;
}


#include <iostream>
using namespace std;

int S[100000];

bool binaryS(int key, int n);

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

  int q, sum = 0;
  cin >> q;
  for (int i = 0; i < q; ++i) {
    int key;
    cin >> key;
    if (binaryS(key, n)) {
      sum++;
    }
  }

  cout << sum << endl;
  return 0;
}

bool binaryS(int key, int n) {

  int l = 0;
  int t = n;

  while (l < t) {
    int s = (l + t) / 2;
    if (S[s] < key) {
      l = s;
    } else if (S[s] > key) {
      t = s;
    } else if (S[s] == key) {
      return true;
    }
  }

  return false;
}

#include <iostream>
using namespace std;

int S[100000];

bool binaryS(int key, int n);

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

  int q, sum = 0;
  cin >> q;
  for (int i = 0; i < q; ++i) {
    int key;
    cin >> key;
    if (binaryS(key, n)) {
      sum++;
    }
  }

  cout << sum << endl;
  return 0;
}

bool binaryS(int key, int n) {

  int l = 0;
  int t = n;

  while (l <= t) {
    int s = (l + t) / 2;
    if (S[s] == key) {
      return true;
    } else if (S[s] < key) {
      l = s + 1;
    } else if (S[s] > key) {
      t = s - 1;
    }
  }

  return false;
}


#include <iostream>
#include <vector>

constexpr int NOT_FOUND = 8101919;

bool IsNotElem(std::vector<int> &done, int x) {
  for (const auto &g : done) {
    if (g == x) {
      return false;
    }
  }
  done.push_back(x);
  return true;
}

void MySwap(int &a, int &b) {
  int tmp = std::move(a);
  a = std::move(b);
  b = std::move(tmp);
}

void BubbleSort(std::vector<int> &vec) {
  int n = vec.size();
  for (int i = 0; i < n; ++i) {
    for (int j = n - 1; j > i; --j) {
      if (vec[j] < vec[j - 1]) {
        MySwap(vec[j], vec[j - 1]);
      }
    }
  }
}

bool BinarySearch(std::vector<int> &v, int key) {
  int left = 0;
  int right = v.size();
  int mid;
  // std::cout << key << ": ";
  while (left < right) {
    mid = (left + right) / 2;
    if (v[mid] == key) {
      // std::cout << key;
      return true;
    } else if (key < v[mid]) {
      right = mid;
    } else {
      left = mid + 1;
    }

    if (key == 1) {
      // std::cout << v[mid] << " ";
    }
  }
  return false;
}

int main() {
  int n;
  std::cin >> n;
  std::vector<int> S(n);
  for (auto &s : S) {
    std::cin >> s;
  }

  int q;
  std::cin >> q;
  std::vector<int> T(q);
  for (auto &t : T) {
    std::cin >> t;
  }

  BubbleSort(T);

  int num = 0;
  std::vector<int> done;
  for (auto &t : T) {
    if (BinarySearch(S, t)) {
      ++num;
    }
    // std::cout << "\\n";
  }
  std::cout << num << "\\n";
}

#include <iostream>
#include <vector>

constexpr int NOT_FOUND = 8101919;

bool IsNotElem(std::vector<int> &done, int x) {
  for (const auto &g : done) {
    if (g == x) {
      return false;
    }
  }
  done.push_back(x);
  return true;
}

void MySwap(int &a, int &b) {
  int tmp = std::move(a);
  a = std::move(b);
  b = std::move(tmp);
}

bool BinarySearch(std::vector<int> &v, int key) {
  int left = 0;
  int right = v.size();
  int mid;
  // std::cout << key << ": ";
  while (left < right) {
    mid = (left + right) / 2;
    if (v[mid] == key) {
      // std::cout << key;
      return true;
    } else if (key < v[mid]) {
      right = mid;
    } else {
      left = mid + 1;
    }

    if (key == 1) {
      // std::cout << v[mid] << " ";
    }
  }
  return false;
}

int main() {
  int n;
  std::cin >> n;
  std::vector<int> S(n);
  for (auto &s : S) {
    std::cin >> s;
  }

  int q;
  std::cin >> q;
  std::vector<int> T(q);
  for (auto &t : T) {
    std::cin >> t;
  }

  int num = 0;
  std::vector<int> done;
  for (auto &t : T) {
    if (BinarySearch(S, t)) {
      ++num;
    }
  }
  std::cout << num << "\\n";
}


#include <stdio.h>
bool search(int *A, int n, int key) {
  int mid, r, l;
  l = 0;
  r = n;
  while (l < r) {
    mid = (r + l) / 2;
    if (A[mid] == key)
      return true;
    if (A[mid] < key)
      l = mid + 1;
    else if (A[mid] > key)
      r = mid;
  }
  return false;
}

int main() {
  int i, n, A[10000 + 1], 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 (search(A, n, key))
      sum++;
  }
  printf("%d\\n", sum);
  return 0;
}

#include <stdio.h>

int A[1000000], n;

bool search(int *A, int key) {
  int mid, r, l;
  l = 0;
  r = n;
  while (l < r) {
    mid = (r + l) / 2;
    if (A[mid] == key)
      return true;
    if (A[mid] < key)
      l = mid + 1;
    else if (A[mid] > key)
      r = mid;
  }
  return false;
}

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 (search(A, key))
      sum++;
  }
  printf("%d\\n", sum);
  return 0;
}


#include <iostream>
using namespace std;
long long S[10001], key;
int n;

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

int main(void) {
  int q, count = 0;
  long long T[501];
  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 (int i = 0; i < q; i++) {
    key = T[i];
    if (binarySearch())
      count++;
  }
  cout << count << endl;
  return 0;
}

#include <iostream>
using namespace std;
long long S[100001], key;
long n;

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

int main(void) {
  long q, count = 0;
  long long T[50001];
  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 (int i = 0; i < q; i++) {
    key = T[i];
    if (binarySearch())
      count++;
  }
  cout << count << endl;
  return 0;
}


#include <cstdio>
#include <iostream>
#include <stack>
#include <vector>

using namespace std;

bool search_ele(int n, vector<int> &S, int ele) {
  int right = 0;
  int left = n;
  while (right < left) {
    int mid = (right + left) / 2;
    if (S[mid] == ele)
      return true;
    if (S[mid] > ele)
      left = mid;
    else
      right = mid;
  }
  return false;
}

int main() {
  int n, q, key;
  int count = 0;
  vector<int> S;
  scanf("%d", &n);
  S.resize(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &S[i]);
  }
  scanf("%d", &q);
  for (int i = 0; i < q; ++i) {
    scanf("%d", &key);
    if (search_ele(n, S, key)) {
      ++count;
    }
  }
  printf("%d\\n", count);
}

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <stack>
#include <vector>

using namespace std;

int main() {
  int n, q, key;
  int count = 0;
  vector<int> S;
  cin >> n;
  S.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> S[i];
  }
  scanf("%d", &q);
  for (int i = 0; i < q; ++i) {
    cin >> key;
    if (*lower_bound(S.begin(), S.end(), key) == key) {
      ++count;
    }
  }
  printf("%d\\n", count);
}


#include <algorithm>
#include <cmath>
#include <iostream>
#include <stack>
#include <vector>
using namespace std;
int calcAve(int bottom, int top) {
  if ((bottom + top) % 2 == 1) {
    return (bottom + top - 1) / 2;
  } else {
    return (bottom + top) / 2;
  }
}
int main() {
  int n;
  cin >> n;
  int S[n];
  for (int i = 0; i < n; i++) {
    cin >> S[i];
  }
  int q;
  cin >> q;
  int T[q];
  for (int i = 0; i < q; ++i) {
    cin >> T[i];
  }
  int score = 0;
  for (int i = 0; i < q; ++i) {

    int bottom = 0;
    int top = n - 1;
    while (top != bottom) {
      if (S[calcAve(bottom, top)] >= T[i]) {
        top = calcAve(bottom, top) - 1;
      } else if (S[calcAve(bottom, top)] < T[i]) {
        bottom = calcAve(bottom, top) + 1;
      }
      if (S[calcAve(bottom, top)] == T[i]) {
        score++;
        break;
      }
      // cout << top << " " << bottom << endl;
    }
  }
  cout << score << endl;
}

#include <algorithm>
#include <cmath>
#include <iostream>
#include <stack>
#include <vector>
using namespace std;
int calcAve(int bottom, int top) {
  if ((bottom + top) % 2 == 1) {
    return (bottom + top - 1) / 2;
  } else {
    return (bottom + top) / 2;
  }
}
int main() {
  int n;
  cin >> n;
  int S[n];
  for (int i = 0; i < n; i++) {
    cin >> S[i];
  }
  int q;
  cin >> q;
  int T[q];
  for (int i = 0; i < q; ++i) {
    cin >> T[i];
  }
  int score = 0;
  for (int i = 0; i < q; ++i) {

    int bottom = 0;
    int top = n - 1;
    while (top >= bottom) {
      if (S[calcAve(bottom, top)] == T[i]) {
        score++;
        break;
      }
      if (S[calcAve(bottom, top)] > T[i]) {
        top = calcAve(bottom, top) - 1;
      } else if (S[calcAve(bottom, top)] < T[i]) {
        bottom = calcAve(bottom, top) + 1;
      }

      // cout << top << " " << bottom << endl;
    }
  }
  cout << score << endl;
}


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

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

int main() {
  int n, s[10100], q, key, count = 0;
  int i, j, k;

  cin >> n;

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

  cin >> q;

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

  cout << count << endl;

  return 0;
}

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

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

int main() {
  int n, s[100100], q, key, count = 0;
  int i, j, k;

  cin >> n;

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

  cin >> q;

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

  cout << count << endl;

  return 0;
}


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

int main() {
  int n, q;
  vector<int> s;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int t;
    scanf("%d", &t);
    s.push_back(t);
  }
  cin >> q;
  int c = 0;
  while (q--) {
    int t;
    scanf("%d", &t);
    int left = 0, right = n + 1;
    bool flag = false;
    while (left <= right) {
      int mid = (left + right) / 2;
      if (s[mid] == t) {
        flag = true;
        break;
      } else if (s[mid] < t) {
        left = mid + 1;
      } else {
        right = mid;
      }
    }
    if (flag) {
      c++;
    }
  }
  cout << c << endl;
}

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

int main() {
  int n, q;
  vector<int> s;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int t;
    scanf("%d", &t);
    s.push_back(t);
  }
  cin >> q;
  int c = 0;
  while (q--) {
    int t;
    scanf("%d", &t);
    int left = 0, right = n;
    bool flag = false;
    while (left < right) {
      int mid = (left + right) / 2;
      if (s[mid] == t) {
        flag = true;
        break;
      } else if (s[mid] < t) {
        left = mid + 1;
      } else {
        right = mid;
      }
    }
    if (flag) {
      c++;
    }
  }
  cout << c << endl;
}


#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
  int n, q;
  int s[100010];
  int t[50010];
  int 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[i];

  for (int ti = 0; ti < q; ti++) {
    int left = 0;
    int right = n - 1;
    while (1) {
      int mid = (left + right) / 2;
      if (t[ti] < s[mid])
        right = mid;
      else
        left = mid;
      if (left == right)
        break;
    }
    if (s[left] == t[ti])
      ans++;
  }

  cout << ans << endl;
  return 0;
}

#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
  int n, q;
  int s[100010];
  int t[50010];
  int 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[i];

  for (int ti = 0; ti < q; ti++) {
    int left = 0;
    int right = n - 1;
    while (1) {
      int mid = (left + right) / 2;
      if (t[ti] < s[mid])
        right = mid;
      if (t[ti] > s[mid])
        left = mid + 1;
      if (t[ti] == s[mid]) {
        ans++;
        break;
      }
      if (left == right) {
        if (s[left] == t[ti]) {
          ans++;
        }
        break;
      }
    }
  }

  cout << ans << endl;
  return 0;
}


#include <algorithm>
#include <stdio.h>

int s[100000];

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

  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &s[i]);
  }
  std::sort(s, s + n);
  scanf("%d", &q);
  for (int i = 0; i < q; ++i) {
    int t;
    scanf("%d", &t);
    int top = 0, end = n;
    while (top < end) {
      int i2 = (end - top) / 2;
      if (t == s[i2]) {
        ++cnt;
        break;
      }
      if (t < s[i2]) {
        end = i2;
      } else {
        top = i2 + 1;
      }
    }
    if (top == end) {
      if (t = s[top]) {
        ++cnt;
      }
    }
  }

  printf("%d\\n", cnt);
}

#include <algorithm>
#include <stdio.h>

int s[100000];

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

  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &s[i]);
  }
  std::sort(s, s + n);
  scanf("%d", &q);
  for (int i = 0; i < q; ++i) {
    int t;
    scanf("%d", &t);
    int top = 0, end = n;
    while (top < end) {
      int i2 = top + (end - top) / 2;
      if (t == s[i2]) {
        ++cnt;
        break;
      }
      if (t < s[i2]) {
        end = i2;
      } else {
        top = i2 + 1;
      }
    }
  }

  printf("%d\\n", cnt);
}


#include <cmath>
#include <cstdio>
#include <iostream>
#include <vector>
int center = 0;

using namespace std;

int binarySearch(vector<int> S, int from, int to, int t) {

  center = floor((from + to) / 2);

  //	printf("(from, center, to) = (%d, %d, %d)\\n", from, center, to);

  if (from >= to) {
    return t == S[center];
  } else if (t == S[center]) {
    return 1;
  } else if (S[center] < t) {
    return binarySearch(S, center + 1, to, t);
  } else if (t < S[center]) {
    return binarySearch(S, from, center - 1, t);
  }
}

int main() {

  vector<int> S;
  vector<int> T; // T?????¢???????????????
  int t, temp;

  scanf("%d", &t);
  for (int i = 0; i < t; i++) {
    scanf("%d", &temp);
    S.push_back(temp);
  }
  scanf("%d", &t);
  for (int i = 0; i < t; i++) {
    scanf("%d", &temp);
    T.push_back(temp);
  }

  int ans = 0;

  for (unsigned int i = 0; i < T.size(); i++) {

    ans += binarySearch(S, 0, S.size() - 1, T[i]);
  }
  cout << ans << endl;

  return 0;
}

#include <cmath>
#include <cstdio>
#include <iostream>
#include <vector>
int center = 0;

using namespace std;

int binarySearch(int *S, int from, int to, int t) {

  center = floor((from + to) / 2);

  //	printf("(from, center, to) = (%d, %d, %d)\\n", from, center, to);

  if (from >= to) {
    return t == S[center];
  } else if (t == S[center]) {
    return 1;
  } else if (S[center] < t) {
    return binarySearch(S, center + 1, to, t);
  } else if (t < S[center]) {
    return binarySearch(S, from, center - 1, t);
  }
}

int main() {

  int *S, *T;
  int S_size, T_size, temp;

  scanf("%d", &S_size);
  S = new int[S_size];
  for (int i = 0; i < S_size; i++) {
    scanf("%d", &temp);
    S[i] = temp;
  }
  scanf("%d", &T_size);
  T = new int[T_size];
  for (int i = 0; i < T_size; i++) {
    scanf("%d", &temp);
    T[i] = temp;
  }

  int ans = 0;

  for (int i = 0; i < T_size; i++) {

    ans += binarySearch(S, 0, S_size - 1, T[i]);
  }
  cout << ans << endl;

  return 0;
}


#include <cmath>
#include <cstdio>
#include <iostream>
#include <vector>
int center = 0;

using namespace std;

int binarySearch(int *S, int S_size, int t) {

  int from = 0, to = S_size - 1, center = (from + to) / 2;

  while (from <= to) {

    if (S[center] == t) {
      return 1;
    } else if (t < S[center]) {
      to = center - 1;
    } else if (S[center] < t) {
      from = center + 1;
    }
  }

  return 0;

  //	printf("(from, center, to) = (%d, %d, %d)\\n", from, center, to);
}

int main() {

  int *S, *T;
  int S_size, T_size, temp;

  scanf("%d", &S_size);
  S = new int[S_size];
  for (int i = 0; i < S_size; i++) {
    scanf("%d", &temp);
    S[i] = temp;
  }
  scanf("%d", &T_size);
  T = new int[T_size];
  for (int i = 0; i < T_size; i++) {
    scanf("%d", &temp);
    T[i] = temp;
  }

  int ans = 0;

  for (int i = 0; i < T_size; i++) {

    ans += binarySearch(S, S_size, T[i]);
  }
  cout << ans << endl;

  return 0;
}

#include <cmath>
#include <cstdio>
#include <iostream>
#include <vector>
int center = 0;

using namespace std;

int binarySearch(int *S, int S_size, int t) {

  int from = 0, to = S_size - 1;

  while (from <= to) {
    center = (from + to) / 2;

    if (S[center] == t) {
      return 1;
    } else if (t < S[center]) {
      to = center - 1;
    } else if (S[center] < t) {
      from = center + 1;
    }
  }

  return 0;

  //	printf("(from, center, to) = (%d, %d, %d)\\n", from, center, to);
}

int main() {

  int *S, *T;
  int S_size, T_size, temp;

  scanf("%d", &S_size);
  S = new int[S_size];
  for (int i = 0; i < S_size; i++) {
    scanf("%d", &temp);
    S[i] = temp;
  }
  scanf("%d", &T_size);
  T = new int[T_size];
  for (int i = 0; i < T_size; i++) {
    scanf("%d", &temp);
    T[i] = temp;
  }

  int ans = 0;

  for (int i = 0; i < T_size; i++) {

    ans += binarySearch(S, S_size, T[i]);
  }
  cout << ans << endl;

  return 0;
}


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> S(n);
  REP(i, n) cin >> S[i];

  int q;
  cin >> q;
  vector<int> T(q);
  REP(i, q) cin >> T[i];

  int ans = 0;

  for (int i = 0; i < n; i++) {
    int key = S[i];
    int left = 0;
    int right = q;
    while (left < right) {
      int mid = (left + right) / 2;
      if (T[mid] == key) {
        ans++;
      } else if (T[mid] > key) {
        right = mid;
      } else {
        left = mid + 1;
      }
    }
  }

  cout << ans << endl;
  return 0;
}

#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> S(n);
  REP(i, n) cin >> S[i];

  int q;
  cin >> q;
  vector<int> T(q);
  REP(i, q) cin >> T[i];

  int ans = 0;

  for (int i = 0; i < q; i++) {
    int key = T[i];
    int left = 0;
    int right = n;
    while (left < right) {
      int mid = (left + right) / 2;
      if (S[mid] == key) {
        ans++;
        break;
      } else if (S[mid] > key) {
        right = mid;
      } else {
        left = mid + 1;
      }
    }
  }

  cout << ans << endl;
  return 0;
}


#include <algorithm>
#include <iostream>
#include <stdlib.h>
using namespace std;

void quick_sort(long int *D, long int B, long int T) {
  if (B >= T)
    return;
  long int i = B, j = T;
  long int div = D[B];

  while (i < j) {
    while (i <= j && D[i] <= div)
      i++;
    while (i <= j && D[j] > div)
      j--;
    if (i < j)
      swap(D[i], D[j]);
  }
  long int tmp = D[B];
  D[B] = D[j];
  D[j] = tmp;
  quick_sort(D, B, j - 1);
  quick_sort(D, j + 1, T);
}

bool binarysearch(long int x, long int *D, long int n) {
  int B = 0;
  int T = n - 1;

  while (B <= T) {
    int mid = (B + T) / 2;
    if (D[mid] == x) {
      return true;
    } else if (D[mid] < x) {
      B = mid + 1;
    } else
      T = mid - 1;
  }
  return false;
}

int main() {
  long int n;
  cin >> n;
  long int S[n];
  for (int i = 0; i < n; i++)
    cin >> S[i];
  long int q;
  cin >> q;
  long int T[q];
  for (int i = 0; i < q; i++)
    cin >> T[i];
  quick_sort(S, 0, n - 1);
  int cnt = 0;
  for (int i = 0; i < q; i++) {
    if (binarysearch(T[i], S, n))
      cnt++;
  }
  cout << cnt << endl;
}

#include <iostream>
#include <stdlib.h>
using namespace std;
bool binarysearch(long int x, long int *D, long int n) {
  int B = 0;
  int T = n - 1;

  while (B <= T) {
    int mid = (B + T) / 2;
    if (D[mid] == x) {
      return true;
    } else if (D[mid] < x) {
      B = mid + 1;
    } else
      T = mid - 1;
  }
  return false;
}

int main() {
  long int n;
  cin >> n;
  long int S[n];
  for (int i = 0; i < n; i++)
    cin >> S[i];
  long int q;
  cin >> q;
  long int T[q];
  for (int i = 0; i < q; i++)
    cin >> T[i];
  int cnt = 0;
  for (int i = 0; i < q; i++) {
    if (binarysearch(T[i], S, n))
      cnt++;
  }
  cout << cnt << endl;
}


#include <iostream>
using namespace std;
void A() {
  int S[10000];
  int T[500];
  int N;
  int Q;
  int C = 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 (int i = 0; i < Q; i++) {
    for (int j = 0; j < N; j++) {
      if (T[i] == S[j]) {
        C++;
        break;
      }
    }
  }

  cout << C << endl;
}

void B() {
  int S[100001];
  int T[50000];
  int N;
  int Q;
  int C = 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 (int i = 0; i < N - 1; i++) {
    for (int j = i + 1; j < N; j++) {
      if (S[i] > S[j]) {
        int tmp = S[i];
        S[i] = S[j];
        S[j] = tmp;
      }
    }
  }

  for (int i = 0; i < Q; i++) {
    int left = 0;
    int right = N;
    while (left < right) {
      int center = (left + right) / 2;

      if (T[i] == S[center]) {
        C++;
        break;
      }

      if (T[i] > S[center]) {
        left = center + 1;
      } else {
        right = center;
      }
    }
  }

  cout << C << endl;
}

int main() {
  // A();
  B();
  return 0;
}

#include <iostream>
using namespace std;
void A() {
  int S[10000];
  int T[500];
  int N;
  int Q;
  int C = 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 (int i = 0; i < Q; i++) {
    for (int j = 0; j < N; j++) {
      if (T[i] == S[j]) {
        C++;
        break;
      }
    }
  }

  cout << C << endl;
}

void B() {
  int S[100001];
  int T[50000];
  int N;
  int Q;
  int C = 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 (int i = 0; i < Q; i++) {
    int left = 0;
    int right = N;
    while (left < right) {
      int center = (left + right) / 2;

      if (T[i] == S[center]) {
        C++;
        break;
      }

      if (T[i] > S[center]) {
        left = center + 1;
      } else {
        right = center;
      }
    }
  }

  cout << C << endl;
}

int main() {
  // A();
  B();
  return 0;
}


#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif
#define y0 qvya13579
#define y1 qvyb24680
#define j0 qvja13579
#define j1 qvjb24680
#define next qvne13579xt
#define prev qvpr13579ev
#define INF 1000000007
#define PI acos(-1.0)
#define endl "\\n"
#define IOS                                                                    \\
  cin.tie(0);                                                                  \\
  ios::sync_with_stdio(false)
#define M_P make_pair
#define PU_B push_back
#define PU_F push_front
#define PO_B pop_back
#define PO_F pop_front
#define U_B upper_bound
#define L_B lower_bound
#define B_S binary_search
#define PR_Q priority_queue
#define FIR first
#define SEC second
#if __cplusplus < 201103L
#define stoi(argument_string) atoi((argument_string).c_str())
#endif
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP_R(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define FOR(i, m, n) for (int i = ((int)(m)); i < (int)(n); ++i)
#define FOR_R(i, m, n) for (int i = ((int)(m)-1); i >= (int)(n); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SIZ(x) ((int)(x).size())
#define COUT(x) cout << (x) << endl
#define CIN(x) cin >> (x)
#define CIN2(x, y) cin >> (x) >> (y)
#define CIN3(x, y, z) cin >> (x) >> (y) >> (z)
#define CIN4(x, y, z, w) cin >> (x) >> (y) >> (z) >> (w)
#define SCAND(x) scanf("%d", &(x))
#define SCAND2(x, y) scanf("%d%d", &(x), &(y))
#define SCAND3(x, y, z) scanf("%d%d%d", &(x), &(y), &(z))
#define SCAND4(x, y, z, w) scanf("%d%d%d%d", &(x), &(y), &(z), &(w))
#define SCANLLD(x) scanf("%lld", &(x))
#define SCANLLD2(x, y) scanf("%lld%lld", &(x), &(y))
#define SCANLLD3(x, y, z) scanf("%lld%lld%lld", &(x), &(y), &(z))
#define SCANLLD4(x, y, z, w) scanf("%lld%lld%lld%lld", &(x), &(y), &(z), &(w))
#define PRINTD(x) printf("%d\\n", (x))
#define PRINTLLD(x) printf("%lld\\n", (x))
typedef long long int lli;
using namespace std;

int ctoi(char c) {
  if (c >= '0' and c <= '9') {
    return (int)(c - '0');
  }

  return -1;
}

int alphabet_pos(char c) {
  if (c >= 'a' and c <= 'z') {
    return (int)(c - 'a');
  }

  return -1;
}

int alphabet_pos_capital(char c) {
  if (c >= 'A' and c <= 'Z') {
    return (int)(c - 'A');
  }

  return -1;
}

vector<string> split(string str, char ch) {
  int first = 0;
  int last = str.find_first_of(ch);

  if (last == string::npos) {
    last = SIZ(str);
  }

  vector<string> result;

  while (first < SIZ(str)) {
    string Ssubstr(str, first, last - first);
    result.push_back(Ssubstr);
    first = last + 1;
    last = str.find_first_of(ch, first);

    if (last == string::npos) {
      last = SIZ(str);
    }
  }

  return result;
}

/*--------------- the end of the template --------------------*/

bool bs(vector<int> S, int T, int left, int right) {
  if (left >= right - 1) {
    return ((T == S[left]) or (T == S[right]));
  }

  if (S[((left + right) / 2)] > T) {
    return bs(S, T, left, ((left + right) / 2));

  } else if (S[((left + right) / 2)] < T) {
    return bs(S, T, ((left + right) / 2), right);

  } else {
    return true;
  }
}

int main() {
  // IOS; /* making cin faster */
  int n, q;
  SCAND(n);
  vector<int> S(n);
  REP(i, n) { SCAND(S[i]); }

  SCAND(q);

  vector<int> T(q);

  REP(i, q) { SCAND(T[i]); }

  sort(ALL(S));

  int cnt = 0;

  REP(i, q) {
    if (bs(S, T[i], 0, n)) {
      ++cnt;
    }
  }

  PRINTD(cnt);
}

#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif
#define y0 qvya13579
#define y1 qvyb24680
#define j0 qvja13579
#define j1 qvjb24680
#define next qvne13579xt
#define prev qvpr13579ev
#define INF 1000000007
#define PI acos(-1.0)
#define endl "\\n"
#define IOS                                                                    \\
  cin.tie(0);                                                                  \\
  ios::sync_with_stdio(false)
#define M_P make_pair
#define PU_B push_back
#define PU_F push_front
#define PO_B pop_back
#define PO_F pop_front
#define U_B upper_bound
#define L_B lower_bound
#define B_S binary_search
#define PR_Q priority_queue
#define FIR first
#define SEC second
#if __cplusplus < 201103L
#define stoi(argument_string) atoi((argument_string).c_str())
#endif
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP_R(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define FOR(i, m, n) for (int i = ((int)(m)); i < (int)(n); ++i)
#define FOR_R(i, m, n) for (int i = ((int)(m)-1); i >= (int)(n); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SIZ(x) ((int)(x).size())
#define COUT(x) cout << (x) << endl
#define CIN(x) cin >> (x)
#define CIN2(x, y) cin >> (x) >> (y)
#define CIN3(x, y, z) cin >> (x) >> (y) >> (z)
#define CIN4(x, y, z, w) cin >> (x) >> (y) >> (z) >> (w)
#define SCAND(x) scanf("%d", &(x))
#define SCAND2(x, y) scanf("%d%d", &(x), &(y))
#define SCAND3(x, y, z) scanf("%d%d%d", &(x), &(y), &(z))
#define SCAND4(x, y, z, w) scanf("%d%d%d%d", &(x), &(y), &(z), &(w))
#define SCANLLD(x) scanf("%lld", &(x))
#define SCANLLD2(x, y) scanf("%lld%lld", &(x), &(y))
#define SCANLLD3(x, y, z) scanf("%lld%lld%lld", &(x), &(y), &(z))
#define SCANLLD4(x, y, z, w) scanf("%lld%lld%lld%lld", &(x), &(y), &(z), &(w))
#define PRINTD(x) printf("%d\\n", (x))
#define PRINTLLD(x) printf("%lld\\n", (x))
typedef long long int lli;
using namespace std;

int ctoi(char c) {
  if (c >= '0' and c <= '9') {
    return (int)(c - '0');
  }

  return -1;
}

int alphabet_pos(char c) {
  if (c >= 'a' and c <= 'z') {
    return (int)(c - 'a');
  }

  return -1;
}

int alphabet_pos_capital(char c) {
  if (c >= 'A' and c <= 'Z') {
    return (int)(c - 'A');
  }

  return -1;
}

vector<string> split(string str, char ch) {
  int first = 0;
  int last = str.find_first_of(ch);

  if (last == string::npos) {
    last = SIZ(str);
  }

  vector<string> result;

  while (first < SIZ(str)) {
    string Ssubstr(str, first, last - first);
    result.push_back(Ssubstr);
    first = last + 1;
    last = str.find_first_of(ch, first);

    if (last == string::npos) {
      last = SIZ(str);
    }
  }

  return result;
}

/*--------------- the end of the template --------------------*/

bool bs(vector<int> S, int T, int n) {
  int left = 0;
  int right = n;
  int mid;

  while (left < right) {
    mid = (left + right) / 2;

    if (S[mid] == T) {
      return true;
    } else if (S[mid] > T) {
      right = mid;

    } else {
      left = mid + 1;
    }
  }

  return ((S[left] == T) or (S[right] == T));
}

int main() {
  // IOS; /* making cin faster */
  int n, q;
  SCAND(n);
  vector<int> S(n);
  REP(i, n) { SCAND(S[i]); }

  SCAND(q);

  vector<int> T(q);

  REP(i, q) { SCAND(T[i]); }

  sort(ALL(S));

  int cnt = 0;

  REP(i, q) {
    if (bs(S, T[i], n)) {
      ++cnt;
    }
  }

  PRINTD(cnt);
}


#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
void output(vector<int> a);
int main(void) {
  int n;
  int q;
  int index = 0;

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

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

  /*for(int i=0 ; i< q; i++){
          if(i!=0){
                  if(T[i-1]>T[i]){
                          n=index;
                          index
                  }

          }
  }*/

  // for(int j=index ; j< n; j++){

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

  cout << count << endl;
}

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
void output(vector<int> a);
int main(void) {
  int n;
  int q;
  // int index=0;

  int count = 0;
  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];
  }

  /*for(int i=0 ; i< q; i++){
          if(i!=0){
                  if(T[i-1]>T[i]){
                          n=index;
                          index
                  }

          }
  }*/

  // for(int j=index ; j< n; j++){

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

  cout << count << endl;
}

terminate called after throwing an instance of 'std::length_error'
  what():  cannot create std::vector larger than max_size()


#include <algorithm>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
// #include <conio.h>
using namespace std;

int binary(int value, const int *array, int size) {
  int lower, upper, mid;
  lower = 0;
  upper = size - 1;

  while (lower <= upper) {

    mid = (lower + upper) / 2;

    if (array[mid] == value) {
      // cout << array[mid] << endl;
      return array[mid];
    } else if (array[mid] < value) {
      lower = mid + 1;
    } else {
      upper = mid - 1;
    }
  }
  return -1;
}

int main() {
  int n, q, sum = 0, size = 0;
  cin >> n;
  vector<int> S;
  for (int i = 0; i < n; ++i) {
    int tmp;
    bool check = true;
    cin >> tmp;
    for (int j = 0; j < size; ++j) {
      if (tmp == S[j])
        check = false;
    }
    if (check == true) {
      // cout << check << " " << tmp <<  endl;
      S.push_back(tmp);
      size++;
    }
  }
  /*for(int i=0; i<size; ++i){
      cout << S[i] << endl;
  }*/
  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());
  for (int i = 0; i < q; ++i) {
    // cout << binary(T[i],&S.front(),S.size()) << endl;
    if (binary(T[i], &S.front(), S.size()) != -1)
      ++sum;
  }
  cout << sum << endl;
  // getch();
  return 0;
}

#include <algorithm>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
// #include <conio.h>
using namespace std;

int binary(int value, const int *array, int size) {
  int lower, upper, mid;
  lower = 0;
  upper = size - 1;

  while (lower <= upper) {

    mid = (lower + upper) / 2;

    if (array[mid] == value) {
      // cout << array[mid] << endl;
      return array[mid];
    } else if (array[mid] < value) {
      lower = mid + 1;
    } else {
      upper = mid - 1;
    }
  }
  return -1;
}

int main() {
  int n, q, sum = 0, size = 0;
  cin >> n;
  vector<int> S(n);
  /*for(int i=0; i<n; ++i){
      int tmp;
      bool check=true;
      cin >> tmp;
      for(int j=0; j<size; ++j){
          if(tmp == S[j]) check = false;
      }
      if(check == true){
          //cout << check << " " << tmp <<  endl;
          S.push_back(tmp);
          size++;
      }
  }*/
  for (int i = 0; i < n; ++i) {
    cin >> S[i];
  }
  /*for(int i=0; i<size; ++i){
      cout << S[i] << endl;
  }*/
  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());
  for (int i = 0; i < q; ++i) {
    // cout << binary(T[i],&S.front(),S.size()) << endl;
    if (binary(T[i], &S.front(), S.size()) != -1)
      ++sum;
  }
  cout << sum << endl;
  // getch();
  return 0;
}


#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

constexpr int Nmax = 100'000;

bool binarySearch(int *array, int value, int n) {
  int left = 0;
  int right = n - 1;
  int center = (left + right) / 2;
  while (array[center] != value) {
    if (left == right) {
      return false;
    }
    if (array[center] > value) {
      right = center - 1;
    } else {
      left = center + 1;
    }
    center = (left + right) / 2;
  }
  return true;
}

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

  int same = 0;

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

  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int value;
    cin >> value;
    if (binarySearch(S, value, n)) {
      same++;
    }
  }
  cout << same << endl;

  return 0;
}

#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

constexpr int Nmax = 100'000;

bool binarySearch(int *array, int value, int n) {
  int left = 0;
  int right = n - 1;
  int center = (left + right) / 2;
  while (array[center] != value) {
    if (left >= right) {
      return false;
    }
    if (array[center] > value) {
      right = center - 1;
    } else {
      left = center + 1;
    }
    center = (left + right) / 2;
  }
  return true;
}

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

  int same = 0;

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

  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int value;
    cin >> value;
    if (binarySearch(S, value, n)) {
      same++;
    }
  }
  cout << same << endl;

  return 0;
}