#include <iostream>
using namespace std;

int main() {
  long long a[200005];
  long long n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long res = a[1] - a[0];
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      if (a[j] >= a[i]) {
        res = a[j] - a[i] > res ? a[j] - a[i] : res;
      }
    }
  }
  cout << res << endl;

  return 0;
}

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

static const int MAX = 200000;

int main() {

  int R[MAX], n;

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

  int maxv = -2000000000;
  int minv = R[0];

  for (int i = 1; i < n; i++) {
    maxv = max(maxv, R[i] - minv);

    minv = min(minv, R[i]);
  }

  cout << maxv << endl;

  return 0;
}


#include <iostream>
using namespace std;

int main() {
  int n;

  cin >> n;

  int value[n];

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

  int max;
  max = value[1] - value[0];

  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (max < value[j] - value[i]) {
        max = value[j] - value[i];
      }
    }
  }

  cout << max << endl;

  return 0;
}

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

static const int MAX = 200000;

int main() {
  int R[MAX], n;

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

  int maxv = -2000000000;
  int minv = R[0];

  for (int i = 1; i < n; i++) {
    maxv = max(maxv, R[i] - minv);
    minv = min(minv, R[i]);
  }

  cout << maxv << endl;

  return 0;
}


#include <iostream>
using namespace std;

int main() {
  int n, i, r, min = 1000000000, max = -1000000000;

  cin >> n;

  cin >> min;
  for (i = 1; i < n; ++i) {
    cin >> r;

    if (r - min > max) {
      max = r - min;
    }
    if (r < min) {
      min = r;
    }
  }

  cout << max << endl;
  return 0;
}


#include <iostream>
using namespace std;

int main() {
  int n, R[200000], max;
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> R[i];
  max = R[1] - R[0];
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      if (R[j] - R[i] > max)
        max = R[j] - R[i];
    }
  }
  cout << max << endl;
}

#include <iostream>

using namespace std;

int main() {
  int n, R[200000], max, min;
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> R[i];
  min = R[0];
  max = R[1] - R[0];
  for (int i = 1; i < n - 1; i++) {
    if (R[i] < min) {
      min = R[i];
    }
    if (R[i + 1] - min > max) {
      max = R[i + 1] - min;
    }
  }
  cout << max << endl;
}


#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iostream>
#include <list>
#include <queue>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <utility>
#include <vector>

#define FOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000            // 2000000000
#define LLINF 1000000000000000000 // 9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair<long long int, long long int> P;

int main(void) {
  int n;
  int r[200001];
  int max = -INF;

  cin >> n;
  FOR(i, 1, n) { cin >> r[i]; }

  FOR(i, 1, n - 1) {
    FOR(t, i + 1, n) {
      if (r[t] - r[i] > max) {
        max = r[t] - r[i];
      }
    }
  }
  cout << max << endl;

  return 0;
}

#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iostream>
#include <list>
#include <queue>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <utility>
#include <vector>

#define FOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000            // 2000000000
#define LLINF 1000000000000000000 // 9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair<long long int, long long int> P;

int main(void) {
  int n;
  int r[200001];
  int maxi = -INF;
  int mini;

  cin >> n;
  FOR(i, 1, n) { cin >> r[i]; }
  mini = r[1];

  FOR(i, 2, n) {
    maxi = max(maxi, r[i] - mini);
    mini = min(mini, r[i]);
  }
  cout << maxi << endl;

  return 0;
}


#include <cmath>
#include <iostream>

int main() {
  int n;
  int x[200000];
  long max = -1e9;

  std::cin >> n;
  for (int i = 0; i < n; i++) {
    std::cin >> x[i];
    for (int j = 0; j < i; j++) {
      long temp = x[i] - x[j]; // 仮の最大値
      max = std::max(temp, max);
    }
  }
  std::cout << max << std::endl;
}

#include <cmath>
#include <iostream>

int main() {
  int n;
  int x[200000];
  int max = -1e9;
  int min = 1e9;

  std::cin >> n;
  std::cin >> x[0];
  min = x[0];

  for (int i = 1; i < n; i++) {
    std::cin >> x[i];
    max = std::max(x[i] - min, max);
    min = std::min(x[i], min);
  }
  std::cout << max << std::endl;
}


#include <iostream>
using namespace std;

int main() {
  int n;
  int R[200000];
  int dif, maxdif = -999999999;

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> R[i];
  }
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      dif = R[j] - R[i];
      if (dif > maxdif)
        maxdif = dif;
    }
  }
  cout << maxdif << endl;

  return 0;
}

#include <algorithm>
#include <iostream>
using namespace std;
static const int MAX = 200000;

int main() {
  int R[MAX], n;

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

  int maxv = -2000000000;
  int minv = R[0];

  for (int i = 1; i < n; i++) {
    maxv = max(maxv, R[i] - minv);
    minv = min(minv, R[i]);
  }
  cout << maxv << endl;

  return 0;
}


#include <algorithm>
#include <iostream>
#include <vector>
int main(void) {
  std::ios::sync_with_stdio(false);
  long long n;
  std::cin >> n;
  std::vector<long long> ValueOnTime(n, 0);
  for (int i = 0; i < ValueOnTime.size(); ++i) {
    std::cin >> ValueOnTime[i];
  }
  int MaxSub = -1e9;
  for (int i = 1; i < ValueOnTime.size(); ++i) {
    long long criterion =
        *max_element((ValueOnTime.begin() + i), ValueOnTime.end()) -
        *min_element(ValueOnTime.begin(), (ValueOnTime.begin() + i));
    if (MaxSub < criterion) {
      MaxSub = criterion;
    }
  }
  std::cout << MaxSub << std::endl;
  // system("pause");
  return 0;
}

#include <algorithm>
#include <iostream>
#include <vector>
int main(void) {
  std::ios::sync_with_stdio(false);
  long long n;
  std::cin >> n;
  std::vector<long long> ValueOnTime(n, 0);
  for (int i = 0; i < ValueOnTime.size(); ++i) {
    std::cin >> ValueOnTime[i];
  }
  int MaxSub = -1e9, Min = ValueOnTime[0];
  for (int i = 1; i < ValueOnTime.size(); ++i) {
    if (MaxSub < ValueOnTime[i] - Min) {
      MaxSub = ValueOnTime[i] - Min;
    }
    if (Min > ValueOnTime[i]) {
      Min = ValueOnTime[i];
    }
  }
  std::cout << MaxSub << std::endl;
  //	system("pause");
  return 0;
}


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

int main() {
  int a, b[200000], c = -2000000000;
  cin >> a;
  for (int i = 0; i < a; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < a; i++) {
    sort(b, b + i);
    if (i == 0) {
      continue;
    } else if (b[i] - b[0] > c)
      c = b[i] - b[0];
  }
  cout << c << endl;
  return 0;
}

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

int main() {
  int a, b[200000], c = -2000000000, d;
  cin >> a;
  for (int i = 0; i < a; i++) {
    cin >> b[i];
  }
  d = b[0];
  for (int i = 0; i < a - 1; i++) {
    if (d > b[i])
      d = b[i];
    if (b[i + 1] - d > c)
      c = b[i + 1] - d;
  }
  cout << c << endl;
  return 0;
}


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

using namespace std;

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

  vector<int> R;
  for (int i = 0; i < n; ++i) {
    int r;
    cin >> r;
    R.push_back(r);
  }

  int profit = numeric_limits<int>::min();
  for (int j = 0; j < n - 1; ++j) {
    for (int k = j + 1; k < n; ++k) {
      profit = max(profit, R[k] - R[j]);
    }
  }
  cout << profit << endl;

  return 0;
}

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

using namespace std;

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

  vector<int> R;
  for (int i = 0; i < n; ++i) {
    int r;
    cin >> r;
    R.push_back(r);
  }

  int maxv = R[1] - R[0];
  int minv = R[0];
  for (int j = 1; j < n; ++j) {
    maxv = max(maxv, R[j] - minv);
    minv = min(minv, R[j]);
  }
  cout << maxv << endl;

  return 0;
}


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

int main() {
  int n, tmp;
  cin >> n;
  vector<int> rt(n);
  for (int i = 0; i < n; i++) {
    cin >> rt[i];
  }
  int ans = INT_MIN;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i < j) {
        tmp = rt[j] - rt[i];
        if (ans < tmp)
          ans = tmp;
      }
    }
  }
  cout << ans << endl;

  return 0;
}

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

int main() {
  int n, tmp;
  cin >> n;
  vector<int> rt(n);
  for (int i = 0; i < n; i++) {
    cin >> rt[i];
  }
  int ans = INT_MIN;
  int minv = rt[0];
  for (int j = 1; j < n; j++) {
    ans = (ans >= rt[j] - minv) ? ans : rt[j] - minv;
    minv = (minv <= rt[j]) ? minv : rt[j];
  }
  cout << ans << endl;

  return 0;
}


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

int main() {
  int N, R[200000];
  int Max = -9999999999;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> R[i];
  }

  for (int i = 0; i < N - 1; i++) {
    for (int j = i + 1; j < N; j++) {

      Max = max(Max, R[j] - R[i]);
    }
  }

  cout << Max << endl;
  return 0;
}

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

int main() {
  int Max, Min;
  int N;
  int R[200000];

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

  Min = R[0];
  Max = -2000000000;

  for (int i = 1; i < N; i++) {
    Max = max(Max, R[i] - Min);
    Min = min(Min, R[i]);
  }

  cout << Max << endl;
  return 0;
}


#include <iostream>
using namespace std;

int main() {
  int n, R[200000];
  int answer = -999999999; //-1000000000;
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> R[i];
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (answer < R[j] - R[i])
        answer = R[j] - R[i];
    }
  }
  cout << answer << endl;

  return 0;
}

#include <iostream>
using namespace std;

int main() {
  int n, R[200000], min;
  int answer = -999999999;
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> R[i];
  min = R[0];
  for (int i = 1; i < n; i++) {
    if (min > R[i]) {
      if (answer < R[i] - min)
        answer = R[i] - min;
      min = R[i];
    } else if (min <= R[i]) {
      if (answer < R[i] - min)
        answer = R[i] - min;
    }
  }
  cout << answer << endl;

  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> R(N);
  for (int i = 0; i < N; ++i)
    cin >> R[i];
  int ans = INT_MIN;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      if (j > i)
        ans = max(ans, R[j] - R[i]);
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> R(N);
  for (int i = 0; i < N; ++i)
    cin >> R[i];
  int mini = R[0];
  int ans = INT_MIN;
  for (int i = 1; i < N; ++i) {
    ans = max(ans, R[i] - mini);
    mini = min(mini, R[i]);
  }
  cout << ans << endl;
  return 0;
}


#include <iostream>
#include <string>
using namespace std;
int main() {
  int n;
  cin >> n;
  int *arr = new int[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  int maxv = arr[1] - arr[0];
  for (int i = 2; i < n; i++) {
    for (int j = 0; j < i; j++) {
      if (arr[i] - arr[j] > maxv)
        maxv = arr[i] - arr[j];
    }
  }
  delete[] arr;
  cout << maxv << endl;
  return 0;
}

#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  int *arr = new int[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  int maxv = arr[1] - arr[0];
  int minv = arr[0];
  for (int i = 1; i < n; i++) {
    maxv = max(maxv, arr[i] - minv);
    minv = min(minv, arr[i]);
  }
  delete[] arr;
  cout << maxv << endl;
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  int ans;
  for (int i = 0; i < n - 1; i++) {
    int x = a.at(i), y = a.at(i + 1);
    for (int j = i + 1; j < n; j++) {
      if (a.at(j) > y)
        y = a.at(j);
    }
    if (i == 0)
      ans = y - x;
    else
      ans = max(ans, y - x);
  }
  cout << ans << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  int x = -2000000000, y = a.at(0);
  for (int i = 1; i < n; i++) {
    x = max(x, a.at(i) - y);
    y = min(y, a.at(i));
  }
  cout << x << endl;
}


#include <iostream>
#include <limits>

int InputAsInt();

int main() {
  int n = InputAsInt();
  int prices[n];
  for (int i = 0; i < n; ++i) {
    prices[i] = InputAsInt();
  }

  int max_profit = std::numeric_limits<int>::min();
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      int profit = prices[j] - prices[i];
      if (profit > max_profit) {
        max_profit = profit;
      }
    }
  }

  std::cout << max_profit << std::endl;
  return 0;
}

int InputAsInt() {
  int result;
  std::cin >> result;
  return result;
}

// 模範解答 from プログラミングコンテスト攻略のためのアルゴリズムとデータ構造
// (マイナビ)

#include <algorithm>
#include <iostream>
using namespace std;
static const int MAX = 200000;

int main() {
  int R[MAX], n;

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

  int maxv = -2000000000; // 問題の制約を踏まえて順分に小さい初期値
  int minv = R[0];

  for (int i = 1; i < n;
       i++) { // "i = 0"は初期値として使用したので"i = 1"からスタート
    maxv = max(maxv, R[i] - minv);
    minv = min(minv, R[i]);
  }

  cout << maxv << endl;
  return 0;
}


/***
 *	?????§?????????
 ****/

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

int main(void) {
  int n;
  cin >> n;
  vector<int> fxR;
  fxR.resize(n);

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

  int maxR = fxR[1] - fxR[0];
  for (int i = 0; i < (n - 1); i++) { // n???????????????????????°??????????¢????
    for (int j = (i + 1); j < n; j++) {
      int tempMax = fxR[j] - fxR[i];
      if (maxR < tempMax) {
        maxR = tempMax;
      }
    }
  }

  cout << maxR << endl; //?????§???????????¨?????????

  return 0;
}

/***
 *	?????§?????????
 ****/

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

int main(void) {
  int n;
  cin >> n;
  vector<int> fxR(n);

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

  int maxR = fxR[1] - fxR[0];
  int minR = fxR[0];

  for (int j = 1; j < n; j++) { // n???????????????????????°??????????¢????
    if (maxR < (fxR[j] - minR)) {
      maxR = fxR[j] - minR;
    }
    if (minR > fxR[j]) {
      minR = fxR[j];
    }
  }

  cout << maxR << endl; //?????§???????????¨?????????

  return 0;
}


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

int main() {
  int n, ans = 1 - 1000000000;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  for (int i = 1; i < n; i++)
    ans = (ans < *max_element(a + i, a + n) - a[i - 1])
              ? *max_element(a + i, a + n) - a[i - 1]
              : ans;
  cout << ans << endl;
}

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

int main() {
  int n, ans, tmp = 1000000001, num;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> num;
    if (i == 1)
      ans = num - tmp;
    if (num >= tmp)
      ans = (num - tmp > ans) ? num - tmp : ans;
    else
      tmp = num;
  }
  cout << ans << endl;
}


#include <iostream>
using namespace std;

int main() {
  int i, j, n, max, R_t[200000];
  cin >> n;
  for (i = 0; i < n; i++)
    cin >> R_t[i];

  max = R_t[1] - R_t[0];
  for (i = 2; i < n; i++) {
    for (j = 0; j < i; j++) {
      if (max < R_t[i] - R_t[j])
        max = R_t[i] - R_t[j];
    }
  }
  cout << max << endl;

  return 0;
}

#include <iostream>
using namespace std;

int main() {
  int i, n, d, min, max, R_t[200000];
  cin >> n >> R_t[0] >> R_t[1];
  min = R_t[0];
  max = R_t[1] - R_t[0];
  if (R_t[0] > R_t[1])
    min = R_t[1];

  for (i = 2; i < n; i++) {
    cin >> R_t[i];
    d = R_t[i] - min;
    if (max < d)
      max = d;
    if (min > R_t[i])
      min = R_t[i];
  }

  cout << max << endl;

  return 0;
}


#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n, a, maxx;
  vector<int> l;
  cin >> n >> a;
  l.push_back(a);
  for (int i = 1; i < n; i++) {
    cin >> a;
    if (i == 1)
      maxx = a - l[0];
    else {
      for (int i = 0; i != l.size(); i++)
        maxx = max(maxx, a - l[i]);
    }
    l.push_back(a);
  }
  cout << maxx << endl;
  return 0;
}

#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  long n;
  cin >> n;
  long long maxx = -2000000000, minx = 2000000000;
  for (int i = 0; i < n; i++) {
    long long x;
    cin >> x;
    maxx = max(maxx, x - minx);
    minx = min(x, minx);
  }
  cout << maxx << endl;
  char c;
  cin >> c;
}


#include <iostream>

using namespace std;

int main() {
  int i, sa = -1000000000, n, r[200000];

  cin >> n;

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

  for (n--; n > 0; n--) {
    for (i = 0; i < n; i++) {
      if (sa < r[n] - r[i]) {
        sa = r[n] - r[i];
      }
    }
  }

  cout << sa << endl;

  return 0;
}

#include <iostream>

using namespace std;

int max_value(int maxv, int max) {
  if (maxv > max) {
    return maxv;
  } else {
    return max;
  }
}

int min_value(int minv, int min) {
  if (minv < min) {
    return minv;
  } else {
    return min;
  }
}

int main() {
  int i, n, r[200000];

  cin >> n;

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

  int maxv = -2000000000;
  int minv = r[0];

  for (i = 1; i < n; i++) {
    maxv = max_value(maxv, r[i] - minv);
    minv = min_value(minv, r[i]);
  }

  cout << maxv << endl;

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[200001] = {};
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i];
  int max = a[1] - a[0];
  for (int i = 1; i < n; i++)
    for (int j = 0; j < i; j++)
      if (a[i] - a[j] > max)
        max = a[i] - a[j];
  cout << max << endl;
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[200001] = {};
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i];
  int max = a[1] - a[0];
  int min = a[0];
  for (int i = 1; i < n; i++) {
    if (a[i] - min > max)
      max = a[i] - min;
    if (min > a[i])
      min = a[i];
  }
  cout << max << endl;
  return 0;
}


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

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

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

  int prices[200000];
  REP(i, n) { cin >> prices[i]; }

  int res = -1e9;
  REP(i, n) {
    FOR(j, i + 1, n) {
      int gap = prices[j] - prices[i];
      if (gap > res)
        res = gap;
    }
  }

  cout << res << endl;
  return 0;
}

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

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

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

  long min = 1e10;
  long res = -1e10;
  REP(i, n) {
    int a;
    cin >> a;

    if (a - min > res)
      res = a - min;
    if (a < min)
      min = a;
  }

  cout << res << endl;
  return 0;
}


#include <iostream>
#define MAXN 200000 + 10
using namespace std;
int s[MAXN];
int t[MAXN];
int ns, nt;
int tot, l, r, mid;
int main() {
  int i, now;
  cin >> ns;
  for (i = 0; i < ns; ++i)
    cin >> s[i];
  cin >> nt;
  for (i = 0; i < nt; ++i)
    cin >> t[i];

  for (i = 0; i < nt; ++i) {
    now = t[i];
    l = 0;
    r = ns;
    while (l < r) {
      mid = l + (r - l) / 2;
      if (s[mid] == now) {
        tot++;
        break;
      }
      if (s[mid] < now)
        l = mid;
      else
        r = mid;
    }
  }
  cout << tot << endl;
  return 0;
}

#include <iostream>
#define MAXN 200000 + 10
using namespace std;
int s[MAXN];
int t[MAXN];
int ns, nt;
int tot, l, r, mid;
int main() {
  int i, now;
  cin >> ns;
  for (i = 0; i < ns; ++i)
    cin >> s[i];
  cin >> nt;
  for (i = 0; i < nt; ++i)
    cin >> t[i];

  for (i = 0; i < nt; ++i) {
    now = t[i];
    l = 0;
    r = ns;
    while (l < r) {
      mid = l + (r - l) / 2;
      if (s[mid] == now) {
        tot++;
        break;
      }
      if (s[mid] < now)
        l = mid + 1;
      else
        r = mid;
    }
  }
  cout << tot << endl;
  return 0;
}


#include <algorithm>
#include <iostream>
#include <list>
#include <stack>

#define REP(i, x, n) for (int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)

using namespace std;

int main() {

  int n;
  cin >> n;
  int num;
  list<int> S;

  rep(i, n) {
    cin >> num;
    S.push_front(num);
  }

  int q;
  cin >> q;
  stack<int> T;
  rep(i, q) {
    cin >> num;
    T.push(num);
  }

  int cnt = 0;
  int l = T.size();
  while (l != 0) {
    num = T.top();
    T.pop();
    for (auto itr = S.begin(); itr != S.end(); itr++) {
      if (num == *itr) {
        cnt++;
        break;
      }
    }
    l--;
  }

  cout << cnt << endl;

  return 0;
}

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

#define REP(i, x, n) for (int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)

using namespace std;

int cnt = 0;

bool binary_search(vector<int> &data, int keyv) {
  int r_ind = data.size();
  int l_ind = 0;
  while (l_ind < r_ind) {
    int c_ind = (l_ind + r_ind) / 2;
    if (data[c_ind] == keyv) {
      return true;
    } else if (keyv < data[c_ind]) {
      r_ind = c_ind;
    } else {
      l_ind = c_ind + 1;
    }
  }
  return false;
}

void solve(vector<int> &sorted, vector<int> &unsorted) {
  int l = unsorted.size();
  for (int i = 0; i < l; i++) {
    if (binary_search(sorted, unsorted[i])) {
      cnt++;
    }
  }
}

int main() {
  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]; }

  solve(S, T);

  cout << cnt << endl;

  return 0;
}


#include <algorithm>
#include <cstdio>

static const size_t n_max = 10000;
static int S[n_max];

int main() {
  size_t n, q;
  scanf("%zu", &n);
  for (size_t i = 0; i < n; i++)
    scanf("%d", S + i);
  scanf("%zu", &q);
  int c = 0;
  for (size_t i = 0; i < q; i++) {
    int t;
    scanf("%d", &t);
    if (std::binary_search(S, S + n, t))
      c++;
  }
  printf("%d\\n", c);
  return 0;
}

#include <algorithm>
#include <cstdio>

static const size_t n_max = 100000;
static int S[n_max];

int main() {
  size_t n, q;
  scanf("%zu", &n);
  for (size_t i = 0; i < n; i++)
    scanf("%d", S + i);
  scanf("%zu", &q);
  int c = 0;
  for (size_t i = 0; i < q; i++) {
    int t;
    scanf("%d", &t);
    if (std::binary_search(S, S + n, t))
      c++;
  }
  printf("%d\\n", c);
  return 0;
}


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

int binarySearch(int A[], int n, int key) {
  int left = 0;
  int right = n - 1;
  int m;

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

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

  cin >> n;
  for (int i = 0; i < n; i++)
    scanf("%d", &S[i]);
  cin >> q;
  for (int i = 0; i < q; i++)
    scanf("%d", &T[i]);

  for (int i = 0; i < q; i++) {
    if (binarySearch(S, n, T[i]))
      sum++;
  }
  cout << sum << endl;
}

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

int binarySearch(int A[], int n, int key) {
  int left = 0;
  int right = n;
  int m;

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

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

  cin >> n;
  for (int i = 0; i < n; i++)
    scanf("%d", &S[i]);
  cin >> q;
  for (int i = 0; i < q; i++)
    scanf("%d", &T[i]);

  for (int i = 0; i < q; i++) {
    if (binarySearch(S, n, T[i]))
      sum++;
  }
  cout << sum << endl;
}


#include <iostream>
using namespace std;

int main() {
  int n = 0;
  int q = 0;
  int S[100000] = {0};
  int T[50000] = {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];

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

#include <iostream>
using namespace std;

int main() {
  int n = 0;
  int q = 0;
  int S[100000] = {0};
  int T[50000] = {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];

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


#include <cstdio>
using namespace std;

#define MAX (1 << 9)
int n, q, t, ans = 0, S[MAX];

int bin(int t, int l = 0, int h = n - 1) {
  if (t == S[l] || t == S[h]) {
    return 1;
  } else if (l == h) {
    return 0;
  } else {
    int m = l + h / 2;
    if (t < S[m]) {
      return bin(t, l, m - 1);
    } else {
      return bin(t, m, h - 1);
    }
  }
}

int main() {
  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);
    ans += bin(t);
  }
  printf("%d\\n", ans);

  return 0;
}

#include <cstdio>
using namespace std;

int n, q, t, ans = 0;

int bin(int t, int *S, int l = 0, int h = n - 1) {
  if (t == S[l] || t == S[h]) {
    return 1;
  } else if (l == h) {
    return 0;
  } else {
    int m = (l + h) / 2;
    if (t < S[m]) {
      return bin(t, S, l, m - 1);
    } else {
      return bin(t, S, m, h - 1);
    }
  }
}

int main() {
  scanf("%d", &n);
  int S[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);
    ans += bin(t, S);
  }
  printf("%d\\n", ans);

  return 0;
}


#include <iostream>
using namespace std;

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

int main(void) {
  int n, q, sum = 0;
  int S[10001], T[10001];

  /* input */

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

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

  for (int i = 0; i < q; i++) {
    if (binarySearch(S, n, T[i])) {
      sum++;
    }
  }

  cout << sum << "\\n";

  return 0;
}

#include <iostream>
using namespace std;

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

int main(void) {
  int n, q, sum = 0;
  int S[100001], T[50001];

  /* input */

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

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

  for (int i = 0; i < q; i++) {
    if (binarySearch(S, n, T[i])) {
      sum++;
    }
  }

  cout << sum << "\\n";

  return 0;
}


#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define rep(i, n) FOR(i, 0, n)
#define DEBUG(x) cout << #x << ": " << x << endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include <map>
#include <queue>
#include <set>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;

int n, q;
ll S[100000], T[50000];

int cond(ll x, ll qq) {
  fprintf(stderr, "%lld %lld\\n", x, qq);

  if (S[x] < qq)
    return 0;
  return 1;
}

ll binarySearch(ll MX, ll qq) {
  ll left = 0;
  ll right = MX;

  if (cond(0, qq) == 1)
    return 0;
  if (cond(MX - 1, qq) == 0)
    return MX;

  while (left + 1 < right) {
    ll mid = (left + right) / 2;
    if (cond(mid, qq) == 0) {
      left = mid;
    } else {
      right = mid;
    }
  }
  return right;
}

bool exist(ll qq) {
  fprintf(stderr, "----- \\n");
  ll bs = binarySearch(n, qq);
  fprintf(stderr, "----- %lld %lld\\n", qq, bs);

  if (bs == n)
    return false;
  return S[bs] == qq;
}

int main() {
  cin >> n;
  rep(i, n) { cin >> S[i]; }
  cin >> q;
  rep(i, q) { cin >> T[i]; }

  int ret = 0;
  rep(i, q) {
    if (exist(T[i]))
      ret++;
  }
  cout << ret << endl;
}

#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define rep(i, n) FOR(i, 0, n)
#define DEBUG(x) cout << #x << ": " << x << endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include <map>
#include <queue>
#include <set>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;

int n, q;
ll S[100000], T[50000];

int cond(ll x, ll qq) {
  // fprintf(stderr, "%lld %lld\\n", x, qq);

  if (S[x] < qq)
    return 0;
  return 1;
}

ll binarySearch(ll MX, ll qq) {
  ll left = 0;
  ll right = MX;

  if (cond(0, qq) == 1)
    return 0;
  if (cond(MX - 1, qq) == 0)
    return MX;

  while (left + 1 < right) {
    ll mid = (left + right) / 2;
    if (cond(mid, qq) == 0) {
      left = mid;
    } else {
      right = mid;
    }
  }
  return right;
}

bool exist(ll qq) {
  // fprintf(stderr, "----- \\n");
  ll bs = binarySearch(n, qq);
  // fprintf(stderr, "----- %lld %lld\\n", qq, bs);

  if (bs == n)
    return false;
  return S[bs] == qq;
}

int main() {
  cin >> n;
  rep(i, n) { cin >> S[i]; }
  cin >> q;
  rep(i, q) { cin >> T[i]; }

  int ret = 0;
  rep(i, q) {
    if (exist(T[i]))
      ret++;
  }
  cout << ret << endl;
}


#include <bits/stdc++.h>

using namespace std;

int main() {

  int n, q;
  long long S[10000], T;
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> S[i];
  cin >> q;

  int count = 0;

  for (int j = 0; j < q; j++) {
    cin >> T;
    int left = 0;
    int right = n;
    int mid = (left + right) / 2;
    while (left < right) {
      mid = (left + right) / 2;
      if (T == S[mid]) {
        count++;
        break;
      }
      if (T > S[mid]) {
        left = mid + 1;
      } else if (T < S[mid]) {
        right = mid;
      }
    }
  }
  cout << count << endl;
  return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main() {

  int n, q;
  long long S[1000000], T;
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> S[i];
  cin >> q;

  int count = 0;

  for (int j = 0; j < q; j++) {
    cin >> T;
    int left = 0;
    int right = n;
    int mid = (left + right) / 2;
    while (left < right) {
      mid = (left + right) / 2;
      if (T == S[mid]) {
        count++;
        break;
      }
      if (T > S[mid]) {
        left = mid + 1;
      } else if (T < S[mid]) {
        right = mid;
      }
    }
  }
  cout << count << endl;
  return 0;
}


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

int main() {
  int n, A[100];
  cin >> n;
  int *pos;
  int sum = 0;

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

  int a, B[100];
  cin >> a;

  for (int i = 0; i < a; i++) {
    cin >> B[i];
    pos = lower_bound(A, A + n, B[i]);
    if (*pos == B[i]) {
      sum++;
    }
  }

  cout << sum << endl;
}

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

int main() {
  int n, A[100000];
  cin >> n;
  int *pos;
  int sum = 0;

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

  int a, B[50000];
  cin >> a;

  for (int i = 0; i < a; i++) {
    cin >> B[i];
    pos = lower_bound(A, A + n, B[i]);
    if (*pos == B[i]) {
      sum++;
    }
  }

  cout << sum << endl;
}


#include <iostream>
#include <vector>

class IntVector : public std::vector<int> {
public:
  void Input(int Count);
  bool Search(int Target) const;
};

void IntVector::Input(int Count) {
  for (int i = 0; i < Count; i++) {
    int Input;
    std::cin >> Input;
    push_back(Input);
  }
}

bool IntVector::Search(int Target) const {
  int left = 0;
  int right = size() - 1;
  int i = left + (right - left) / 2;
  while (left < right) {
    if (at(i) == Target)
      return true;
    if (at(i) < Target) {
      left = i;
    } else {
      right = i;
    }
    i = left + (right - left) / 2;
  }
  return false;
}

int main() {
  int n = 0;
  std::cin >> n;
  IntVector S;
  S.Input(n);
  int q = 0;
  std::cin >> q;
  int Count = 0;
  for (int i = 0; i < q; i++) {
    int T;
    std::cin >> T;
    Count += S.Search(T);
  }

  std::cout << Count << std::endl;
  return 0;
}

#include <iostream>
#include <vector>

class IntVector : public std::vector<int> {
public:
  void Input(int Count);
  bool Search(int Target) const;
};

void IntVector::Input(int Count) {
  for (int i = 0; i < Count; i++) {
    int Input;
    std::cin >> Input;
    push_back(Input);
  }
}

bool IntVector::Search(int Target) const {
  int left = 0;
  int right = size() - 1;
  int i = 0;
  while (left <= right) {
    i = left + (right - left) / 2;
    if (at(i) == Target)
      return true;
    if (at(i) < Target) {
      left = i + 1;
    } else {
      right = i - 1;
    }
  }
  return false;
}

int main() {
  int n = 0;
  std::cin >> n;
  IntVector S;
  S.Input(n);
  int q = 0;
  std::cin >> q;
  int Count = 0;
  for (int i = 0; i < q; i++) {
    int T;
    std::cin >> T;
    Count += S.Search(T);
  }

  std::cout << Count << std::endl;
  return 0;
}


#include <cstdio>
#include <iostream>

using namespace std;

int main() {

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

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

  int cnt = 0;

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

    int left = 0;
    int right = n - 1;
    int mid = right - left;

    while (1) {
      if (T > S[mid]) {
        if (mid + 1 > n - 1) {
          break;
        }
        left = mid + 1;
      } else if (T < S[mid]) {
        if (mid - 1 < 0) {
          break;
        }
        right = mid - 1;
      } else {
        ++cnt;
        break;
      }
      mid = right - left;
    }
  }

  cout << cnt << endl;
  return 0;
}

#include <cstdio>
#include <iostream>

using namespace std;

int main() {

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

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

  int cnt = 0;

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

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

    while (left < right) {
      if (T > S[mid]) {
        left = mid + 1;
      } else if (T < S[mid]) {
        right = mid;
      } else {
        ++cnt;
        break;
      }
      mid = (right + left) / 2;
    }
  }

  cout << cnt << endl;
  return 0;
}


#include <iostream>
using namespace std;

int main() {
  int n, q;

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

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

  cout << count << endl;

  return 0;
}

#include <iostream>
using namespace std;

int main() {
  int n, q;

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

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

  cout << count << endl;

  return 0;
}


#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define rep(i, n) FOR(i, 0, n)
#define DEBUG(x) cout << #x << ": " << x << endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include <map>
#include <queue>
#include <set>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;
int NS;
int S[MAX_N];
int NT;
int T[MAX_N];

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

int main() {

  cin >> NS;
  rep(i, NS) { cin >> S[i]; }
  cin >> NT;
  rep(i, NT) { cin >> T[i]; }

  int ret = 0;
  rep(i, NT) {
    if (binarySearch(S, NS, T[i]) >= 0)
      ret++;
  }
  cout << ret << endl;
}

#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define rep(i, n) FOR(i, 0, n)
#define DEBUG(x) cout << #x << ": " << x << endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include <map>
#include <queue>
#include <set>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;
int NS;
int S[MAX_N];
int NT;
int T[MAX_N];

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

int main() {

  cin >> NS;
  rep(i, NS) { cin >> S[i]; }
  cin >> NT;
  rep(i, NT) { cin >> T[i]; }

  int ret = 0;
  rep(i, NT) {
    if (binarySearch(S, NS, T[i]) >= 0)
      ret++;
  }
  cout << ret << endl;
}


#include <stdio.h>

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

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

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

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

  return 0;
}

#include <stdio.h>

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

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

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

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

  return 0;
}


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

int main(void) {
  int n, q;
  cin >> n;
  int s[n];

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

  for (int i = 0; i < q; i++) {
    cin >> t[i];
  }
  int count = 0;
  for (int i = 0; i < q; i++) {
    int low = 0;
    int high = n;
    int mid = (low + high) / 2;
    while (low <= high) {
      if (t[i] == s[mid]) {
        count++;
      } else if (t[i] > s[mid]) {
        low = mid + 1;
      } else {
        high = mid - 1;
      }
      int mid = (low + high) / 2;
    }
  }
  cout << count << endl;
}

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

int main(void) {
  int n, q;
  cin >> n;
  int s[n];

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

  for (int i = 0; i < q; i++) {
    cin >> t[i];
  }
  int count = 0;
  for (int i = 0; i < q; i++) {
    int low = 0;
    int high = n;
    while (low <= high) {
      int mid = (low + high) / 2;
      if (t[i] == s[mid]) {
        count++;
        break;
      } else if (t[i] > s[mid]) {
        low = mid + 1;
      } else {
        high = mid - 1;
      }
    }
  }
  cout << count << endl;
}


#include <iostream>
int main() {
  int n, q, count = 0;

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

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

  int flag = 0, search, searchF, searchE;
  for (int k = 0; k < q; k++) {
    flag = 0;
    search = n / 2;
    searchF = 0;
    searchE = n - 1;
    while (flag == 0) {

      if (S[searchF] == S[searchE]) {
        flag = 1;
      }
      if (S[search] == T[k]) {
        count++;
        break;

      } else if (S[search] > T[k]) {
        searchE = search - 1;
        search = (searchF + searchE) / 2;
      } else {
        searchF = search + 1;
        search = (searchF + searchE) / 2;
      }
    }
  }
  std::cout << count << "\\n";
  return 0;
}

#include <iostream>

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

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

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

  std::cin >> q;
  int T[q];
  for (int i = 0; i < q; i++) {
    std::cin >> T[i];
    if (binarySearch(T[i], S, n))
      count++;
  }

  /*	int flag=0,search,searchF,searchE;
    for(int k=0;k<q;k++){
          flag=0;
          search=n/2;
          searchF=0;
          searchE=n-1;
          */
  /*
  while(flag==0){

          if(S[searchF]==S[searchE]){
                  flag=1;
          }
          if(S[search]==T[k]){
                  count++;
                  break;

          }else if(S[search]>T[k]){
                  searchE=search-1;
                  search=(searchF+searchE)/2;
          }else{
                  searchF=search+1;
                  search=(searchF+searchE)/2;
          }

  }

}
  */
  std::cout << count << "\\n";
  return 0;
}


#include <cstdio>
using namespace std;

int A[100000];

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

int main() {
  int n, q, key;
  int cnt = 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(key, n))
      cnt++;
  }
  printf("%d\\n", cnt);
  return 0;
}

#include <cstdio>
using namespace std;

int A[100000];

int search(int key, int n) {
  int left = 0;
  int right = n;
  int mid;
  while (left < right) { //??????????????£?????????notfound
    mid = (left + right) / 2;
    if (A[mid] == key)
      return 1;
    else if (key < A[mid]) { // motto left
      right = mid;
    } else {
      left = mid + 1; //?????¶???????????????????
    }
  }
  return 0;
}

int main() {
  int n, q, key;
  int cnt = 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(key, n))
      cnt++;
  }
  printf("%d\\n", cnt);
  return 0;
}


#include <iostream>
using namespace std;

int linesearch(int a[], int n, int key) {
  for (int i = 0; i < n; i++) {
    if (a[i] == key)
      return 1;
  }
  return false;
}

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

#include <iostream>
using namespace std;
int s[100100];
int linesearch(int a[], int n, int key) {
  for (int i = 0; i < n; i++) {
    if (a[i] == key)
      return 1;
  }
  return false;
}

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


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

using namespace std;

bool binary_search(vector<int> v, int kay, bool is_sorted) {
  if (is_sorted)
    sort(ALL(v));

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

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

  int n;
  cin >> n;

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

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

  cout << count << endl;
}

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

using namespace std;

bool binary_search(vector<int> v, int kay, bool is_sorted) {
  if (!is_sorted)
    sort(ALL(v));

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

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

  int n;
  cin >> n;

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

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

  cout << count << endl;
}


#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <string.h>
using namespace std;
int a[100000], b[100000], c[50000];
int main() {
  int n, m;
  while (scanf("%d", &n) != EOF) {
    memset(a, 0, sizeof(a));
    memset(b, 0, sizeof(b));
    memset(c, 0, sizeof(c));
    for (int i = 0; i < n; i++) {
      scanf("%d", &a[i]);
      b[a[i]]++;
    }
    sort(a, a + n);

    scanf("%d", &m);
    for (int i = 0; i < m; i++) {
      scanf("%d", &c[i]);
      for (int j = 0; j <= a[n - 1]; j++)
        if (b[c[i]] != 0)
          b[c[i]] = -1;
    }
    sort(c, c + m);
    int sum = 0, y;
    if (a[n - 1] >= c[m - 1])
      y = a[n - 1];
    else
      y = c[m - 1];
    for (int i = 0; i <= y; i++) {
      if (b[i] == -1)
        sum++;
    }
    printf("%d\\n", sum);
  }
  return 0;
}

#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <string.h>
using namespace std;
int x[100100], y[50010], z[150110];
int main() {
  int n, m;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%d", &x[i]);
  int a = unique(x, x + n) - x;
  scanf("%d", &m);
  for (int i = 0; i < m; i++)
    scanf("%d", &y[i]);
  sort(y, y + m);
  int b = unique(y, y + m) - y;
  for (int i = 0; i < a; i++)
    z[i] = x[i];
  for (int i = a; i < a + b; i++)
    z[i] = y[i - a];
  sort(z, z + a + b);
  int t = unique(z, z + a + b) - z;
  printf("%d\\n", a + b - t);
}


#include <cstdio>
#include <iostream>
using namespace std;
const int N = 1e6 + 10;
int a[N], n;
int binarysearch(int key) {
  int left = 0;
  int right = n;
  int mid;
  while (left < right) {
    mid = (left + right) / 2;
    if (key == a[mid])
      return 1;
    if (key > a[mid])
      left = mid + 1;
    else if (key < a[mid])
      right = mid;
  }
  return 0;
}
int main() {
  int i, q, key, sum = 0;
  cin >> n;
  for (i = 0; i < n; i++)
    cin >> a[i];
  cin >> q;
  for (i = 0; i < q; i++) {
    cin >> key;
    if (binarysearch(key))
      sum++;
  }
  cout << sum << endl;
  return 0;
}


#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
int a[10005], n;
int binarySearch(int key) {
  int left = 0, right = n;
  int mid;
  while (left < right) {
    mid = (left + right) / 2;
    if (key == a[mid])
      return 1;
    if (key > a[mid])
      left = mid + 1;
    if (key < a[mid])
      right = mid;
  }
  return 0;
}

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  int q;
  scanf("%d", &q);
  int sum = 0;
  for (int i = 0; i < q; i++) {
    int jie;
    scanf("%d", &jie);
    if (binarySearch(jie))
      sum++;
  }
  printf("%d\\n", sum);
  return 0;
}

#include <cstdio>

int n, A[1000010];

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

int main() {
#ifdef LOCAL
  freopen("E:\\\\Temp\\\\input.txt", "r", stdin);
  freopen("E:\\\\Temp\\\\output.txt", "w", stdout);
#endif

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

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

  return 0;
}


//============================================================================
// Name        : procon.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

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

int main() {
  int n, q, sum;
  vector<int> S, T;

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

  cin >> q;
  for (int j = 0; j < q; j++) {
    int val;
    cin >> val;
    T.push_back(val);
  }

  for (auto v1 : T) {
    for (auto v2 : S) {
      if (v1 == v2) {
        sum++;
        break;
      }
    }
  }

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

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

int BinarySearch(vector<int> A, int key) {
  int left = 0;
  int right = A.size();

  while (left < right) {
    int 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, q, c = 0;
  vector<int> S, T;

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

  cin >> q;
  for (int j = 0; j < q; j++) {
    int v;
    cin >> v;
    T.push_back(v);
  }

  for (auto v1 : T) {
    if (BinarySearch(S, v1)) {
      c++;
    }
  }
  cout << c << endl;
  return 0;
}


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

bool BinarySearch(int t, vector<int> S) {
  int start = 0;
  int end = S.size() - 1;
  do {
    int middle = (end - start) / 2 + start;
    if (t == S[middle]) {
      return true;
    } else if (t < S[middle]) {
      end = middle - 1;
    } else if (t > S[middle]) {
      start = middle;
    }
  } while (end - start >= 1);
  return false;
}

int main() {
  int Count = 0;
  int n;
  cin >> n;
  vector<int> S;
  for (int i = 0; i < n; i++) {
    int s;
    cin >> s;
    S.push_back(s);
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int t;
    cin >> t;
    if (BinarySearch(t, S)) {
      Count++;
    }
  }
  cout << Count << endl;
  return 0;
}

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

bool BinarySearch(int t, vector<int> S) {
  int start = 0;
  int end = S.size() - 1;
  do {
    int middle = (end - start) / 2 + start;
    if (t == S[middle]) {
      return true;
    } else if (t < S[middle]) {
      end = middle - 1;
    } else if (t > S[middle]) {
      start = middle + 1;
    }
    //		cout << t << " " << start << " " << middle " " << end << endl;
  } while (end - start >= 0);
  return false;
}

int main() {
  int Count = 0;
  int n;
  cin >> n;
  vector<int> S;
  for (int i = 0; i < n; i++) {
    int s;
    cin >> s;
    S.push_back(s);
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int t;
    cin >> t;
    if (BinarySearch(t, S)) {
      Count++;
      //			cout << "t:" << t << endl;
    }
  }
  cout << Count << endl;
  return 0;
}


#include <iostream>
#include <stdlib.h>

using namespace std;
int ceil(double x) { return (int)(x + 0.9); }
int binarySearch(int n, int *s, int q, int *t) {
  int sum = 0;

  for (int i = 0; i < q; i++) {
    int mid = ceil(n / 2);
    double left = 0;
    double right = n - 1;
    while (right != left) {
      if (s[mid] == t[i]) {
        sum++;
        break;
      }
      if (s[mid] > t[i]) {
        right = mid;
        mid = left + ceil((right - left) / 2);
      }
      if (s[mid] < t[i]) {
        left = mid;
        mid = mid + ceil((right - left) / 2);
      }
    }
  }
  return sum;
}
int main() {
  int n = 0;
  int q = 0;
  cin >> n;

  int *s = (int *)malloc(sizeof(int) * n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &s[i]);
  }
  cin >> q;
  int *t = (int *)malloc(sizeof(int) * q);
  for (int i = 0; i < q; i++) {
    scanf("%d", &t[i]);
  }
  int sum = binarySearch(n, s, q, t);
  printf("%d\\n", sum);
  return 0;
}

#include <iostream>
#include <stdlib.h>

using namespace std;
int ceil(double x) { return (int)(x + 0.9); }
int binarySearch(int n, int *s, int q, int *t) {
  int sum = 0;

  for (int i = 0; i < q; i++) {
    int mid = n / 2;
    int left = 0;
    int right = n;
    while (left != right) {
      if (s[mid] == t[i]) {
        sum++;
        break;
      }
      if (s[mid] > t[i]) {
        right = mid;
        mid = (left + right) / 2;
      }
      if (s[mid] < t[i]) {
        left = mid;
        mid = (left + right) / 2;
      }
      if (left == mid || right == mid) {
        break;
      }
    }
  }
  return sum;
}
int main() {
  int n = 0;
  int q = 0;
  cin >> n;

  int *s = (int *)malloc(sizeof(int) * n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &s[i]);
  }
  cin >> q;
  int *t = (int *)malloc(sizeof(int) * q);
  for (int i = 0; i < q; i++) {
    scanf("%d", &t[i]);
  }
  int sum = binarySearch(n, s, q, t);
  printf("%d\\n", sum);
  return 0;
}


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

int getSameNum(int[], int[], int, int);

int main() {
  int n, q;
  scanf("%d", &n);
  int s[n];
  for (int i = 0; i < n; i++)
    scanf("%d", &s[i]);
  scanf("%d", &q);
  int t[q];
  for (int i = 0; i < q; i++)
    scanf("%d", &t[i]);
  sort(t, t + q);
  printf("%d\\n", getSameNum(s, t, n, q));
  return 0;
}

int getSameNum(int s[], int t[], int n, int q) {
  int cnt = 0;
  for (int i = 0; i < q; i++)
    for (int j = 0; j < n; j++)
      if (t[i] == s[j]) {
        cnt++;
        break;
      }
  return cnt;
}

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

int getSameNum(int[], int[], int, int);

int main() {
  int n, q;
  scanf("%d", &n);
  int s[n];
  for (int i = 0; i < n; i++)
    scanf("%d", &s[i]);
  scanf("%d", &q);
  int t[q];
  for (int i = 0; i < q; i++)
    scanf("%d", &t[i]);
  sort(t, t + q);
  printf("%d\\n", getSameNum(s, t, n, q));
  return 0;
}

int getSameNum(int s[], int t[], int n, int q) {
  int cnt = 0, mem = 0;
  for (int i = 0; i < q; i++)
    for (int j = mem; j < n; j++)
      if (t[i] == s[j]) {
        cnt++;
        mem = j;
        break;
      }
  return cnt;
}


#include <iostream>
#include <map>
#include <set>
#include <vector>

int main(void) {
  int ans = 0;
  int n, q;
  std::cin >> n;
  std::vector<int> arr(n);
  for (auto &a : arr)
    std::cin >> a;
  std::cin >> q;
  for (size_t i = 0; i < q; i++) {
    int in = 0;
    std::cin >> in;
    int left = 0, mid = n / 2, right = n;
    while (left != right) {
      if (arr[mid] == in) {
        ans++;
        break;
      }
      if (in < arr[mid])
        right = mid;
      else
        left = mid;

      mid = (right + left) / 2;
    }
  }

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

#include <iostream>
#include <map>
#include <set>
#include <vector>

int main(void) {
  int ans = 0;
  int n, q;
  std::cin >> n;
  std::vector<int> arr(n);
  for (auto &a : arr)
    std::cin >> a;
  std::cin >> q;
  for (size_t i = 0; i < q; i++) {
    int in = 0;
    std::cin >> in;
    int left = 0, mid = n / 2, right = n;
    while (left != right) {
      if (arr[mid] == in) {
        ans++;
        break;
      }
      if (in < arr[mid])
        right = mid;
      else
        left = mid + 1;

      mid = (right + left) / 2;
    }
  }

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


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

#define S_SIZE 100000

using namespace std;

int S[S_SIZE];

bool isContain(int left, int right, int number) {
  int m = (left + right) / 2;
  if (left == right && S[m] != number) {
    return false;
  } else if (S[m] == number) {
    return true;
  } else if (S[m] < number) {
    return isContain(m + 1, right, number);
  } else { // S[m] > number
    return isContain(left, m - 1, number);
  }
}

int main() {

  int tmp;
  int n, q, count = 0;

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

  int left, right;
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d", &tmp);
    left = 0;
    right = n - 1;
    if (isContain(left, right, tmp))
      count++;
  }
  printf("%d\\n", count);
}

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

#define S_SIZE 100000

using namespace std;

int S[S_SIZE];

bool isContain(int left, int right, int number) {
  int m = (left + right) / 2;
  if (left == right) {
    if (S[m] == number) {
      return true;
    } else {
      return false;
    }
  } else if (S[m] == number) {
    return true;
  } else if (S[m] < number) {
    return isContain(m + 1, right, number);
  } else { // S[m] > number
    if (right - left == 1) {
      return isContain(left, m, number);
    } else {
      return isContain(left, m - 1, number);
    }
  }
}

int main() {

  int tmp;
  int n, q, count = 0;

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

  int left, right;
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d", &tmp);
    left = 0;
    right = n - 1;
    if (isContain(left, right, tmp)) {
      count++;
    }
  }
  printf("%d\\n", count);
}


#include <iostream>

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

  int left = 0;
  int right = n;
  int mid = n / 2;

  while (left < right) {

    if (ary[mid] == key)
      return 1;

    else if (key < ary[mid])
      right = mid;

    else
      left = mid + 1;

    mid = (left + right) / 2;
  }

  return 0;
}

int main() {

  int i, j, key, answer;
  int num_of_ary, num_of_key;
  int ary[10010];

  answer = 0;

  std::cin >> num_of_ary;
  for (i = 0; i <= num_of_ary - 1; i++)
    std::cin >> ary[i];

  std::cin >> num_of_key;
  for (i = 0; i <= num_of_key - 1; i++) {

    std::cin >> key;
    answer += binarySearch(ary, num_of_ary, key);
  }

  std::cout << answer << std::endl;
  return 0;
}

#include <iostream>

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

  int left = 0;
  int right = n;
  int mid = n / 2;

  while (left < right) {

    if (ary[mid] == key)
      return 1;

    else if (key < ary[mid])
      right = mid;

    else
      left = mid + 1;

    mid = (left + right) / 2;
  }

  return 0;
}

int main() {

  int i, j, key, answer;
  int num_of_ary, num_of_key;
  int ary[100010];

  answer = 0;

  std::cin >> num_of_ary;
  for (i = 0; i <= num_of_ary - 1; i++)
    std::cin >> ary[i];

  std::cin >> num_of_key;
  for (i = 0; i <= num_of_key - 1; i++) {

    std::cin >> key;
    answer += binarySearch(ary, num_of_ary, key);
  }

  std::cout << answer << std::endl;
  return 0;
}


#include <cstdio>

int A[1000000], n;

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

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

  return 0;
}

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

#include <cstdio>

int A[1000000], n;

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

  while (left < right) {
    mid = (left + right) / 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() {
  int q, k, 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", &k);
    if (binarySearch(k))
      sum++;
  }
  printf("%d\\n", sum);
}


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

// ?????§????´¢
bool BinarySearch(int A[], int n, int key) {
  int left = 0, right = n, mid;

  while (left < right) {
    mid = (left + right) / 2;
    if (key == A[mid])
      return true;

    if (key > A[mid])
      left = mid + 1;
    if (key < A[mid])
      right = mid;
  }
  return false;
}
int main() {
  int n, q, key;
  int sum = 0;
  int A[10000 + 10];
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%d", &A[i]);
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d", &key);
    if (BinarySearch(A, n, key))
      sum++;
  }
  printf("%d\\n", sum);
}

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

// ?????§????´¢
bool BinarySearch(int A[], int n, int key) {
  int left = 0, right = n, mid;

  while (left < right) {
    mid = (left + right) / 2;
    if (key == A[mid])
      return true;

    if (key > A[mid])
      left = mid + 1;
    if (key < A[mid])
      right = mid;
  }
  return false;
}
int main() {
  int n, q, key;
  int sum = 0;
  int A[100000 + 10];
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%d", &A[i]);
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d", &key);
    if (BinarySearch(A, n, key))
      sum++;
  }
  printf("%d\\n", sum);
}


#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <set>
using namespace std;
set<int> p, q;
set<int>::iterator pit;
set<int>::iterator qit;
int main() {
  int n, m;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    p.insert(a);
  }
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    int b;
    scanf("%d", &b);
    q.insert(b);
  }

  int cnt = 0;
  for (pit = p.begin(); pit != p.end(); pit++) {
    for (qit = q.begin(); qit != q.end(); qit++) {
      if (*pit == *qit) {
        cnt++;
        break;
      }
    }
  }
  printf("%d\\n", cnt);
  return 0;
}

#include <algorithm>
#include <cstdio>
#include <cstdlib>
using namespace std;
int a[100001];
int b[100001];

int binarySearch(int a[], int n, int data) {
  int left = 0, right = n - 1;
  while (left <= right) {
    int mid = (left + right) / 2;
    if (a[mid] == data) {
      return mid;
    } else if (a[mid] < data) {
      left = mid + 1;
    } else {
      right = mid - 1;
    }
  }
  return -1;
}
int main() {
  int n, m;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    scanf("%d", &b[i]);
  }

  int cnt = 0;
  for (int i = 0; i < m; i++) {
    if (binarySearch(a, n, b[i]) >= 0) {
      cnt++;
    }
  }
  printf("%d\\n", cnt);
  return 0;
}


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

#define MAX_N (10010)
#define MAX_Q (510)
int n;
int q;
vector<int> S;
int T[MAX_Q];

bool bilinear_search(int key) {
  int h = 0;
  int t = n;
  while (h < t) {
    int mid = (h + t) >> 1;
    if (S[mid] == key)
      return true;
    else if (key < S[mid]) {
      t = mid;
    } else {
      h = mid + 1;
    }
  }
  return false;
}

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int s;
    scanf("%d", &s);
    S.push_back(s);
  }

  sort(S.begin(), S.end());

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

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

  return 0;
}

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

int n;
int q;
vector<int> S;

bool binary_search(int key) {
  int h = 0;
  int t = n;

  while (h < t) {
    int mid = (h + t) >> 1;
    if (S[mid] == key) {
      return true;
    } else if (key < S[mid]) {
      t = mid;
    } else {
      h = mid + 1;
    }
  }

  return false;
}

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int s;
    scanf("%d", &s);
    S.push_back(s);
  }

  scanf("%d", &q);
  int ans = 0;
  for (int i = 0; i < q; i++) {
    int t;
    scanf("%d", &t);
    if (binary_search(t))
      ans++;
  }

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

  return 0;
}


#include <cstdio>
#include <iostream>

using namespace std;
int A[100000 + 10], n;

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

int main() {
  int i, q, key, sum = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%d", &A[i]);
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d", &key);
    if (binary_searcher(key))
      sum++;
  }
  printf("%d", sum);
  return sum;
}

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

// 二分搜索
bool BinarySearch(int A[], int n, int key) {
  int left = 0, right = n, mid;

  while (left < right) {
    mid = (left + right) / 2;
    if (key == A[mid])
      return true;

    if (key > A[mid])
      left = mid + 1;
    if (key < A[mid])
      right = mid;
  }
  return false;
}
int main() {
  int n, q, key;
  int sum = 0;
  int A[100000 + 10];
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%d", &A[i]);
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d", &key);
    if (BinarySearch(A, n, key))
      sum++;
  }
  printf("%d\\n", sum);
}


#include <iostream>

using namespace std;
long A[1000000], n;

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

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


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

using namespace std;

static int n;
static int *S;

bool find(int t) {
  int left = -1;
  int right = n;

  while (right - left > 1) {
    int x = (right - left) / 2;
    if (S[x] < t) {
      left = x;
    } else {
      right = x;
    }
  }
  if (S[right] == t) {
    return true;
  }
  return false;
}
int main() {
  int count = 0;
  cin >> n;
  S = new int[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &S[i]);
  }

  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int t = 0;
    scanf("%d", &t);
    if (find(t)) {
      count++;
    }
  }

  delete[] S;

  cout << count << endl;

  return 0;
}

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

using namespace std;

int n;
int *S;

bool find(int t) {
  int left = -1;
  int right = n;

  while (right - left > 1) {
    int x = (right + left) / 2;
    if (S[x] < t) {
      left = x;
    } else {
      right = x;
    }
  }
  if (S[right] == t) {
    return true;
  }
  return false;
}
int main() {
  int count = 0;
  cin >> n;
  S = new int[n];
  for (int i = 0; i < n; i++) {
    string str;
    cin >> str;
    S[i] = atoi(str.c_str());
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int t;
    string str;
    cin >> str;
    t = atoi(str.c_str());
    if (find(t)) {
      count++;
    }
  }

  delete[] S;

  cout << count << endl;

  return 0;
}


#include <iostream>
#include <map>
#include <vector>

using namespace std;

int main() {
  int n, q;
  cin >> n;
  vector<int> S(n);
  for (int i = 0; i < n; i++)
    cin >> S[i];
  cin >> q;
  vector<int> T(q);
  for (int i = 0; i < q; i++)
    cin >> T[i];
  map<int, int> m;

  int sum = 0;
  for (int x : T) {
    if (m.find(x) != m.end() && m[x] == 1) {
      sum++;
    } else {
      int low = 0, high = n - 1, mid;
      while (low <= high) {
        mid = (low + high) / 2;
        if (S[mid] == x) {
          sum++;
          m[x] = 1;
          break;
        } else if (S[mid] > x) {
          high = mid - 1;
        } else
          low = mid + 1;
      }
    }
  }
  cout << sum;
  return 0;
}

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

using namespace std;

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

  int sum = 0;

  for (int i = 0; i < q; i++) {
    int x = T[i];
    int low = 0, high = n - 1, mid;
    while (low <= high) {
      mid = (low + high) / 2;
      if (S[mid] == x) {
        sum++;
        break;
      } else if (S[mid] > x) {
        high = mid - 1;
      } else
        low = mid + 1;
    }
  }
  cout << sum << endl;
  return 0;
}


/*
 * Problem Description: Linear Search
 * Category:
 * Author: Khan
 * Date: 13th October, 2017
 */

#include <algorithm>
#include <cstdio>

using namespace std;

int main(int argc, char const *argv[]) {
  // freopen("sample.txt", "r", stdin);
  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 (binary_search(A, A + n, key))
      sum++;
  }
  printf("%d\\n", sum);
  return 0;
}

/*
 * Problem Description: Linear Search
 * Category:
 * Author: Khan
 * Date: 13th October, 2017
 */

#include <algorithm>
#include <cstdio>

int main(int argc, char const *argv[]) {
  // freopen("sample.txt", "r", stdin);
  int i, n, A[1000000], 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 (std::binary_search(A, A + n, key))
      sum++;
  }
  printf("%d\\n", sum);
  return 0;
}


#include <cstdio>
#include <iostream>

using namespace std;
int A[10001], m;
int search(int key) {
  int left = 0;
  int right = m;
  int mid;

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

int main(int argc, char const *argv[]) {
  int n, i, sum = 0, key;
  scanf("%d", &m);
  for (i = 0; i < m; ++i) {
    scanf("%d", &A[i]);
  }

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

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
vector<int> ivec1, ivec2;
int n, q, a;
bool binarySearch(vector<int> &v, int key) {
  int left = 0, right = n, mid;
  while (left < right) {
    mid = (left + right) >> 1;
    if (key < v[mid])
      right = mid;
    else
      left = mid + 1;
  }
  left--;
  if (left >= 0 && v[left] == key) {
    return true;
  } else
    return false;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a);
    ivec1.push_back(a);
  }
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d", &a);
    ivec2.push_back(a);
  }
  sort(ivec1.begin(), ivec1.end());
  int sum = 0;
  for (int i = 0; i < q; i++) {
    if (binarySearch(ivec1, ivec2[i]))
      sum++;
  }
  printf("%d\\n", sum);
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
int a[100005];
int n, q;
// bool BinarySearch(int l,int r,int k){
//	int mi=(l+r)/2;
//	if(l>=r&&a[mi]!=k)return false;
//	if(a[mi]==k)return true;
//	if(a[mi]<k)return BinarySearch(mi+1,r,k);
//	else return BinarySearch(l,mi-1,k);
// }
bool BinarySearch(int l, int r, int k) {
  int mi;
  while (l < r) {
    mi = (l + r) / 2;
    if (a[mi] == k)
      return true;
    else if (a[mi] < k)
      l = mi;
    else
      r = mi;
  }
  return false;
}
int main() {
  //	freopen("a.txt","r",stdin);
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i];
  //	sort(a,a+n);
  cin >> q;
  int res = 0, number;
  for (int i = 0; i < q; i++) {
    cin >> number;
    if (BinarySearch(0, n - 1, number))
      res++;
    //		if(*lower_bound(a,a+n,number)==number)res++;
  }
  cout << res << endl;
  return 0;
}

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

int n, m;
int s[100005];
int q[50005];
bool search(int x) {
  int t = lower_bound(s, s + n, x) - s;
  if (s[t] == x)
    return true;
  else
    return false;
}
int main() {
  int sum = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%d", &s[i]);
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    scanf("%d", &q[i]);
    if (search(q[i]))
      sum++;
  }
  printf("%d\\n", sum);
  return 0;
}


#include <cstdio>
#include <iostream>
using namespace std;
int a[10010];
int main() {
  int n, m, h = 0, b;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%d", &a[i]);
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    scanf("%d", &b);
    for (int j = 0; j < n; j++)
      if (b == a[j]) {
        h++;
        break;
      }
  }
  printf("%d\\n", h);
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
int a[100005];
int n, q;
int main() {
  //	freopen("a.txt","r",stdin);
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i];
  //	sort(a,a+n);
  cin >> q;
  int res = 0, number;
  for (int i = 0; i < q; i++) {
    cin >> number;
    if (*lower_bound(a, a + n, number) == number)
      res++;
  }
  cout << res << endl;
  return 0;
}


#include <algorithm>
#include <cstdio>
#include <cstdlib>

void P(int l, int d, int n, int a[], int &h) {
  if (l == d - 1) {
    if (n == a[l] || n == a[d])
      h = 1;
    else
      h = 0;
  }
  int mid = (d + l) / 2;
  if (n < a[mid])
    P(1, mid, n, a, h);
  else if (n > a[mid])
    P(mid + 1, d, n, a, h);
}

int main() {
  int n, q;
  scanf("%d \\n", &n);
  int a[n + 1];
  for (int i = 1; i <= n; i++)
    scanf("%d ", &a[i]);
  scanf("\\n");
  scanf("%d \\n", &q);
  int t[q + 1];
  for (int i = 1; i <= q; i++)
    scanf("%d ", &t[i]);
  scanf("\\n");
  int s = 0;
  int h = 0;
  for (int i = 1; i <= q; i++) {
    P(1, n, t[i], a, h);
    s = s + h;
  }
  printf("%d ", s);
  return 0;
}

// #include <bits/stdc++.h>
#include <algorithm>
#include <cstdio>
#include <iostream>
#define ll long long
using namespace std;
int A[1000010], n;

int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &A[i]);
  }
  int q, k, sum = 0;
  cin >> q;
  for (int j = 0; j < q; ++j) {
    scanf("%d", &k);
    if (*lower_bound(A, A + n, k) == k)
      sum++;
  }
  cout << sum << endl;
  return 0;
}


#include <cstdio>
#include <iostream>

using namespace std;

int binary_searcher(int A[], int key, int n) {
  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 i, q, key, n, sum = 0;
  int A[100000 + 10];
  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 (binary_searcher(A, key, n))
      sum++;
  }
  printf("%d", sum);

  return 0;
}

#include <cstdio>
#include <iostream>

using namespace std;

int binary_searcher(int A[], int key, int n) {
  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 i, q, key, n, sum = 0;
  int A[100000 + 10];
  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 (binary_searcher(A, key, n))
      sum++;
  }
  printf("%d\\n", sum);
  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 - 1;
      else if (S[(a + b) / 2] == T[i]) {
        C++;
        break;
      } else
        a = (a + b) / 2;
    }
  }
  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 <cmath>
#include <iostream>
#define int long long

using namespace std;

int S[100100];
int n, q;
int T;

signed main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> S[i];
  }
  cin >> q;
  int L = 0;
  int R = n;
  int cnt = 0;
  int mid;
  for (int i = 0; i < q; i++) {
    cin >> T;
    L = 0;
    R = n;
    for (int j = 0; j < n / 2; j++) {
      int mid = (L + R) / 2;
      // cout<<mid<<endl;
      if (S[L] == T) {
        cnt++;
        // cout<<"succes"<<endl;
        break;
      } else if (S[mid] <= T) {
        L = mid;
      } else if (S[mid] > T) {
        R = mid;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}

#include <algorithm>
#include <cmath>
#include <iostream>
#define int long long

using namespace std;

int S[100100];
int n, q;
int T;

signed main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> S[i];
  }
  cin >> q;
  int L = 0;
  int R = n;
  int cnt = 0;
  int mid;
  for (int i = 0; i < q; i++) {
    cin >> T;
    L = 0;
    R = n;
    for (int j = 0; j < 18; j++) {
      int mid = (L + R) / 2;
      // cout<<mid<<endl;
      if (S[L] == T) {
        cnt++;
        // cout<<"succes"<<endl;
        break;
      } else if (S[mid] <= T) {
        L = mid;
      } else if (S[mid] > T) {
        R = mid;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}


#include <stdio.h>

int A[1000000], n;

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

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

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

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

  return 0;
}

#include <stdio.h>

int A[1000000], n;

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

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

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

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

  return 0;
}


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

int S[10000];
int n, q;
int C;

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

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

int S[100000];
int n, q;
int C;

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


#include <bits/stdc++.h>
using namespace std;
int S[1000000] = {0};
int t[50000] = {0};

int main() {
  int n, q, k, ans = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> k;
    S[k] = 1;
  }
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> k;
    ++t[k];
    ans += t[k] * S[k];
  }
  cout << ans << endl;
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
int S[1000000] = {0};
int T[50000] = {0};

int main() {
  int n, q, k, 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];
  }
  sort(T, T + q);
  sort(S, S + n);
  int t = 0, s = 0;
  k = -1;
  while (s < n && t < q) {
    if (S[s] == T[t]) {
      if (T[t] != k)
        ++ans;
      ++s;
      k = T[t];
    } else if (S[s] > T[t]) {
      ++t;
    } else if (S[s] < T[t]) {
      ++s;
    }
  }
  cout << ans << endl;

  return 0;
}


#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 8;
int n, q, x, num;
int s[maxn];

bool is_find(int x) {
  int left, right, mid;
  left = 0;
  right = n;
  while (left <= right) {
    mid = (left + right) / 2;
    if (s[mid] == x)
      return true;
    else if (s[mid] > x) {
      right = mid;
    } else if (s[mid] < x) {
      left = mid + 1;
    }
  }
  return false;
}
int main() {
  scanf("%d", &n);
  num = 0;
  for (int i = 0; i < n; ++i)
    scanf("%d", &s[i]);
  sort(s, s + n);
  scanf("%d", &q);
  for (int i = 0; i < q; ++i) {
    scanf("%d", &x);
    if (is_find(x))
      num++;
  }
  printf("%d\\n", num);
  return 0;
}

#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 8;
int n, q, x, num;
int s[maxn];

bool is_find(int x) {
  int left, right, mid;
  left = 0;
  right = n;
  while (left < right) {
    mid = (left + right) / 2;
    if (s[mid] == x)
      return true;
    else if (s[mid] > x) {
      right = mid;
    } else if (s[mid] < x) {
      left = mid + 1;
    }
  }
  return false;
}
int main() {
  scanf("%d", &n);
  num = 0;
  for (int i = 0; i < n; ++i)
    scanf("%d", &s[i]);
  sort(s, s + n);
  scanf("%d", &q);
  for (int i = 0; i < q; ++i) {
    scanf("%d", &x);
    if (is_find(x))
      num++;
  }
  printf("%d\\n", num);
  return 0;
}


#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const int maxn = 1e6 + 8;
int n, q, x, num;
int s[maxn];

bool is_find(int x) {
  int left, right, mid;
  left = 0;
  right = n;
  while (left <= right) {
    mid = (left + right) / 2;
    if (s[mid] == x)
      return true;
    else if (s[mid] > x) {
      right = mid;
    } else if (s[mid] < x) {
      left = mid + 1;
    }
  }
  return false;
}
int main() {
  scanf("%d", &n);
  num = 0;
  for (int i = 0; i < n; ++i)
    scanf("%d", &s[i]);
  sort(s, s + n);
  scanf("%d", &q);
  for (int i = 0; i < q; ++i) {
    scanf("%d", &x);
    if (is_find(x))
      num++;
  }
  printf("%d\\n", num);
  return 0;
}

#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 8;
int n, q, x, num;
int s[maxn];

bool is_find(int x) {
  int left, right, mid;
  left = 0;
  right = n;
  while (left < right) {
    mid = (left + right) / 2;
    if (s[mid] == x)
      return true;
    else if (s[mid] > x) {
      right = mid;
    } else if (s[mid] < x) {
      left = mid + 1;
    }
  }
  return false;
}
int main() {
  scanf("%d", &n);
  num = 0;
  fill(s, s + maxn, 0);
  for (int i = 0; i < n; ++i)
    scanf("%d", &s[i]);
  sort(s, s + n);
  scanf("%d", &q);
  for (int i = 0; i < q; ++i) {
    scanf("%d", &x);

    if (is_find(x)) {
      num++;
    }
  }
  printf("%d\\n", num);
  return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main(void) {
  int n, m, c = 0, in;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];

  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> in;
    int r = 0, l = n;

    while (l - r > 0) {
      //  cout<<in<<" "<<l<<" "<<r<<endl;
      int mid = (l + r) / 2;
      if (a[mid] == in) {
        c++;
        break;
      }

      if (a[mid] < in) {
        r = mid;
      } else {
        l = mid;
      }
      if (l - r == 0)
        break;
    }
  }
  cout << c << endl;
}

#include <iostream>
#include <vector>

using namespace std;

int main(void) {
  int n, m, c = 0, in;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];

  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> in;
    int r = 0, l = n;

    while (l > r) {
      //  cout<<in<<" "<<l<<" "<<r<<endl;
      int mid = (l + r) / 2;
      if (a[mid] == in) {
        c++;
        break;
      }

      if (a[mid] < in) {
        r = mid + 1;
      } else {
        l = mid;
      }
    }
  }
  cout << c << endl;
}


#include <iostream>
using namespace std;

int S[100000];
int T[50000];

bool binarySearch(int key, int n) {
  int head = 0, tail = n - 1;
  int mid = (head + tail) / 2;
  if (key < S[head] || key > S[tail])
    return false;
  while (1) {
    if (S[mid] == key || S[mid + 1] == key)
      return true;
    else if (key < S[mid])
      tail = mid;
    else if (key > S[mid])
      head = mid;
    else if (head == tail - 1 && (key != S[head] && key != S[tail]))
      return false;
    mid = (head + tail) / 2;
  }
}

int main() {
  int n, q, count = 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 (binarySearch(T[i], n))
      count++;
  }
  cout << count << endl;
}

#include <iostream>
using namespace std;

int A[1000000], n;

/* 二部探索 */
int binarySearch(int key) {
  int left = 0;
  int right = n;
  int mid;
  while (left < right) {
    mid = (left + right) / 2;
    if (key == A[mid])
      return 1; /* keyを発見 */
    if (key > A[mid])
      left = mid + 1; /* 後半を探索 */
    else if (key < A[mid])
      right = mid; /* 前半を探索 */
  }
  return 0;
}

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

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


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

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

  return false;
}

int main() {
  int countN, n[10000], countQ;

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

  cin >> countQ;
  int t, match = 0;
  for (int i = 0; i < countQ; i++) {
    scanf("%d", t);
    if (binarySearch(n, countN, t))
      match++;
  }

  cout << match << endl;

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

  int match = 0;
  for (int i = 0; i < countQ; i++) {
      if (binarySearch(n, countN, t[i])) match++;
  }

  cout << match << endl;
  ***/

  /***
  int match = 0;
  for (int j = 0; j < countQ; j++) {
      for (int i = 0; i < countN; i++) {
          if (n[i] == t[j]) {
              match++;
              break;
          }
      }
  }
  cout << match << endl;
  ***/
}

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

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

  return false;
}

int main() {
  int countN, n[999999], countQ;

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

  cin >> countQ;
  int t = 0, match = 0;
  for (int i = 0; i < countQ; i++) {
    cin >> t;
    if (binarySearch(n, countN, t))
      match++;
  }

  cout << match << endl;

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

  int match = 0;
  for (int i = 0; i < countQ; i++) {
      if (binarySearch(n, countN, t[i])) match++;
  }

  cout << match << endl;
  ***/

  /***
  int match = 0;
  for (int j = 0; j < countQ; j++) {
      for (int i = 0; i < countN; i++) {
          if (n[i] == t[j]) {
              match++;
              break;
          }
      }
  }
  cout << match << endl;
  ***/
}


#include <iostream>
#include <sstream>

int main() {
  int n1, cnt = 0;
  std::cin >> n1;
  int S[n1];
  for (int i = 0; i < n1; i++) {
    std::cin >> S[i];
  }
  int n2;
  std::cin >> n2;
  int T[n2];
  for (int i = 0; i < n2; i++) {
    std::cin >> T[i];
  }

  int left = 0;
  int right = n1 - 1;
  int c, num;
  for (int i = 0; i < n2; i++) {
    num = T[i];
    left = 0;
    right = n1 - 1;
    while (left < right) {
      c = int((left + right) / 2.0);
      if (S[c] > num) {
        right = c;
      }
      if (S[c] < num) {
        left = c;
      }
      if (S[c] == num) {
        cnt++;
        break;
      }
    }
  }
  std::cout << cnt << '\\n';
  return 0;
}

#include <iostream>
#include <sstream>

int main() {
  int n1, cnt = 0;
  std::cin >> n1;
  int S[n1];
  for (int i = 0; i < n1; i++) {
    std::cin >> S[i];
  }
  int n2;
  std::cin >> n2;
  int T[n2];
  for (int i = 0; i < n2; i++) {
    std::cin >> T[i];
  }

  int left = 0;
  int right = n1 - 1;
  int c, num;
  for (int i = 0; i < n2; i++) {
    num = T[i];
    left = 0;
    right = n1 - 1;
    while (left <= right) {
      c = int((left + right) / 2.0);
      if (S[c] > num) {
        right = c - 1;
      }
      if (S[c] < num) {
        left = c + 1;
      }
      if (S[c] == num) {
        cnt++;
        break;
      }
    }
  }
  std::cout << cnt << '\\n';
  return 0;
}


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

int BinSearch(int nA[], int nKey, int n) {
  int nLeft = 0, nRight = n;
  int nMid = (nLeft + nRight) / 2;
  while (nLeft < nRight) {

    if (nA[nMid] < nKey) {
      nLeft = nMid;
    } else if (nA[nMid] > nKey) {
      nRight = nMid;
    } else {
      return nMid != n;
    }
    nMid = (nLeft + nRight) / 2;
  }
}

int main() {
  int nA[100000] = {0};
  int n = 0, q = 0, nKey = 0, nSum = 0;
  int ni = 0;
  cin >> n;
  while (cin >> nA[ni], ni < (n - 1)) {
    ni++;
  }
  cin >> q;
  for (ni = 0; ni < q; ni++) {
    cin >> nKey;
    if (BinSearch(nA, nKey, n)) {
      nSum++;
    }
  }
  cout << nSum << endl;
  return 0;
}

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

int BinSearch(int nA[], int nKey, int n) {
  int nLeft = 0, nRight = n;
  int nMid = (nLeft + nRight) / 2;
  while (nLeft < nRight) {
    if (nA[nMid] < nKey) {
      nLeft = nMid + 1;
    } else if (nA[nMid] > nKey) {
      nRight = nMid;
    } else {
      return 1;
    }
    nMid = (nLeft + nRight) / 2;
  }
  return 0;
}

int main() {
  int nA[100000] = {0};
  int n = 0, q = 0, nKey = 0, nSum = 0;
  int ni = 0;
  cin >> n;
  while (cin >> nA[ni], ni < (n - 1)) {
    ni++;
  }
  cin >> q;
  for (ni = 0; ni < q; ni++) {
    cin >> nKey;
    if (BinSearch(nA, nKey, n)) {
      nSum++;
    }
  }
  cout << nSum << endl;
  return 0;
}


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

int main() {
  int n = 0, q = 0, k = 0;
  long t = 0;

  cin >> n;
  vector<long> S(n);
  vector<long>::iterator st;

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

  cin >> q;

  for (int i = 0; i < q; i++) {
    cin >> t;
    st = find(S.begin(), S.end(), t);
    if (st != S.end())
      k++;
  }

  cout << k << endl;

  return 0;
}

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

int main() {
  int n = 0, q = 0, k = 0, max = 0, min = 0;
  long t = 0;

  cin >> n;
  vector<long> S(n);

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

  cin >> q;

  for (int i = 0; i < q; i++) {
    cin >> t;
    max = n - 1;
    min = 0;

    while (max >= min) {
      if (t > S[(min + max) / 2])
        min = (min + max) / 2 + 1;
      else if (t < S[(min + max) / 2])
        max = (min + max) / 2 - 1;
      else {
        k++;
        break;
      }
    }
  }

  cout << k << endl;

  return 0;
}


#include <iostream>

#define MAXN 100000
#define MAXQ 50000

using namespace std;

int n, q;
int S[MAXN + 1], T[MAXQ + 1];
int cnt = 0;

bool binarySearch(int num) {
  int lo, mi, hi;
  bool res = false;
  lo = 0;
  mi = hi = n;
  while (1 < mi) {
    mi = (lo + hi) / 2;
    if (num < S[mi]) {
      hi = mi - 1;
    } else if (S[mi] < num) {
      lo = mi + 1;
    } else {
      res = true;
      break;
    }
  }

  return res;
}

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

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

  return 0;
}

#include <iostream>

#define MAXN 100000
#define MAXQ 50000

using namespace std;

int n, q;
int S[MAXN + 1], T[MAXQ + 1];
int cnt = 0;

bool binarySearch(int num) {
  int lo, mi, hi;
  bool res = false;
  lo = 0;
  mi = hi = n;
  while (lo <= hi) {
    mi = (lo + hi) / 2;
    if (num < S[mi]) {
      hi = mi - 1;
    } else if (S[mi] < num) {
      lo = mi + 1;
    } else {
      res = true;
      break;
    }
  }

  return res;
}

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

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

  return 0;
}


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

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

int main() {
  int N;
  int S[100000];
  int q;
  int T[20000];
  int count = 0;

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

  for (int j = 0; j < q; j++) {
    if (binarySearch(T[j], N, S))
      count++;
  }

  cout << count << endl;

  return 0;
}

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

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

int main() {
  int N;
  int S[200000];
  int q;
  int T[50000];
  int count = 0;

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

  for (int j = 0; j < q; j++) {
    if (binarySearch(T[j], N, S))
      count++;
  }

  cout << count << endl;

  return 0;
}