#include <iostream>
using namespace std;

int A[10001], n;

int binarySearch(int key) {
  int left = 0;
  int right = n;
  int i = 0;
  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 q, i, k, ans = 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))
      ans++;
  }

  cout << ans << endl;

  return 0;
}

#include <iostream>
using namespace std;

int A[100000], n;

int binarySearch(int key) {
  int left = 0;
  int right = n;
  int i = 0;
  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 q, i, k, ans = 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))
      ans++;
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

int S[100000];

int main(void) {

  int n;
  cin >> n;

  memset(S, -1, sizeof(int) * 100000);
  for (int i = 0; i < n; ++i) {
    int s;
    cin >> s;
    int j = 0;
    while (S[j] != -1 && S[j] != s) {
      //            printf("[insert] j = %d\\n", j);
      if (s < S[j]) {
        j = j * 2 + 1;
      } else {
        j = j * 2 + 2;
      }
    }
    S[j] = s;
  }

  int q, total = 0;
  cin >> q;
  for (int i = 0; i < q; ++i) {
    int t;
    cin >> t;
    int j = 0;
    while (S[j] != -1) {
      if (S[j] == t) {
        ++total;
        break;
      } else if (S[j] < t) {
        j = j * 2 + 2;
      } else {
        j = j * 2 + 1;
      }
    }
  }

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

  return 0;
}

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

using namespace std;

int S[100000];

int main(void) {

  int n;
  cin >> n;

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

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

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

  return 0;
}


#include <iostream>
using namespace std;
int main() {
  int n, S[100000], q, T[50000], c = 0, i, i2, toread, cnt;
  cin >> n;
  for (i = 0; i < n; i++)
    cin >> S[i];
  cin >> q;
  for (i = 0; i < q; i++)
    cin >> T[i];
  for (i = 0; i < n; i++) {
    for (i2 = 0; i2 < n; i2++) {
      if (S[i] < S[i2]) {
        toread = S[i];
        S[i] = S[i2];
        S[i2] = toread;
      }
    }
  }
  for (i = 0; i < q; i++) {
    cnt = 0;
    toread = n;
    while (toread > 1) {
      if (toread % 2 == 0)
        toread /= 2;
      else
        toread = (toread + 1) / 2;
      if (S[(toread - 1) + cnt] < T[i])
        cnt += toread;
      else if (S[(toread - 1) + cnt] == T[i]) {
        c++;
        break;
      }
    }
  }
  cout << c << endl;
}

#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int n, S[100000], q, T[50000], c = 0, i, i2, toread, cnt;
  cin >> n;
  for (i = 0; i < n; i++)
    cin >> S[i];
  cin >> q;
  for (i = 0; i < q; i++)
    cin >> T[i];
  /*for(i=0;i<n;i++){
          for(i2=0;i2<n;i2++){
                  if(S[i]<S[i2]){
                          toread=S[i];
                          S[i]=S[i2];
                          S[i2]=toread;
                  }
          }
  }*/
  sort(S, S + n);
  for (i = 0; i < q; i++) {
    cnt = 0;
    toread = n;
    while (toread > 1) {
      if (toread % 2 == 0)
        toread /= 2;
      else
        toread = (toread + 1) / 2;
      if (S[(toread - 1) + cnt] < T[i])
        cnt += toread;
      else if (S[(toread - 1) + cnt] == T[i]) {
        c++;
        break;
      }
    }
  }
  cout << c << endl;
}


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

using namespace std;

int binary_search(int key, int left, int right) {
  int center = (left + right) / 2;

  if (left == right && key != left) {
    return 0;
  }

  if (key == center) {
    return 1;
  } else if (key < center) {
    return binary_search(key, left, center);
  } else {
    return binary_search(key, center, right);
  }
}

int main() {
  int n, q, s[100000] = {0}, t[50000] = {0};
  int 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];
    count = binary_search(t[i], s[0], s[n - 1]);
  }

  cout << count << endl;

  return 0;
}

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

using namespace std;

int s[100000] = {0};

int binary_search(int key, int left, int right) {
  int center;

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

    if (s[center] == key) {
      return 1;
    } else if (s[center] < key) {
      left = center + 1;
    } else {
      right = center;
    }
  }

  return 0;
}

int main() {
  int n, q, t[50000] = {0};
  int 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];
    count += binary_search(t[i], 0, n);
  }

  cout << count << endl;

  return 0;
}


#include <stdio.h>
using namespace std;

int n, s[10000];

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

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

#include <stdio.h>

int s[1000000], n;

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

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

int main(void) {
  int i, q, t, c = 0;

  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &s[i]);
  }
  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    scanf("%d", &t);
    if (binarySearch(t))
      c++;
  }
  printf("%d\\n", c);
  return 0;
}


#include <iostream>
using namespace std;

int D[100010];

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

#include <iostream>
using namespace std;

int D[100010];

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


#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[10000], b, c[10000], i, k = 0, j;
  for (cin >> n, i = 0; i < n; i++)
    cin >> a[i];
  for (cin >> b, i = 0; i < b; i++)
    cin >> c[i];
  for (i = 0; i < b; i++)
    if (binary_search(a, a + n, c[i]))
      k++;
  cout << k << endl;
}

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, a[100000], b, c[50000], i, k = 0, j;
  for (cin >> n, i = 0; i < n; i++)
    cin >> a[i];
  for (cin >> b, i = 0; i < b; i++)
    cin >> c[i];
  for (i = 0; i < b; i++)
    if (binary_search(a, a + n, c[i]))
      k++;
  cout << k << endl;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, sum = 0, p;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  int m;
  cin >> m;
  while (m--) {
    int p;
    cin >> p;
    int l = 0, r = n;
    while (l < r) {
      int mid = (l + r) / 2 + 1;
      if (a[mid] == p) {
        sum++;
        break;
      }
      if (p < a[mid])
        r = mid;
      else
        l = mid;
    }
  }
  cout << sum << endl;
}

#include <bits/stdc++.h>
using namespace std;
main() {
  int n, sum = 0, p;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  int m;
  cin >> m;
  while (m--) {
    cin >> p;
    int l = 0, r = n;
    while (l < r) {
      int mid = (l + r) / 2;
      if (a[mid] == p) {
        sum++;
        break;
      }
      if (p < a[mid])
        r = mid;
      else
        l = mid + 1;
    }
  }
  cout << sum << endl;
}


#include <iostream>
using namespace std;

int main() {
  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 x = 0;
  int mid;
  int left = 0;
  int right = n;
  for (int j = 0; j < q; j++) {
    left = 0;
    right = n;
    while (left < right) {
      mid = (left + right) / 2;
      if (S[mid] == T[j]) {
        x++;
        break;
      } else if (T[j] < S[mid]) {
        right = mid;
      } else if (T[j] > S[mid]) {
        left = mid;
      }
    }
  }
  cout << x << endl;

  return 0;
}

#include <iostream>
using namespace std;

int main() {
  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 x = 0;
  int mid;
  int left = 0;
  int right = n;
  for (int j = 0; j < q; j++) {
    left = 0;
    right = n;
    while (left < right) {
      mid = (left + right) / 2;
      if (S[mid] == T[j]) {
        x++;
        break;
      } else if (T[j] < S[mid]) {
        right = mid;
      } else if (T[j] > S[mid]) {
        left = mid + 1;
      }
    }
  }
  cout << x << endl;

  return 0;
}


// 含有标记的线性搜索可以将算法效率提高常数倍
// for(int i=0;i<n;i++)
// s[n]==key;while(s[i]!=key)i++;if(i!=n)
// 区别在于主循环中比较运算的次数
#include <cstdio>
#include <iostream>
using namespace std;
int s[10004];
int cnt, n;
/*void LinearSearch(int s[],int num)
{
        for(int i=0;i<n;i++)
        {
                if(s[i]==num)
                {
                        cnt++;
                        break;
                }
        }
}*/
int BinarySearch(int key) {
  int left = 0;
  int right = n;
  while (left < right) {
    int mid = (left + right) / 2;
    if (s[mid] == key) {
      // cout<<"1"<<endl;
      return 1;
    } else if (key < s[mid]) // 前半部分
    {
      right = mid;
    } else // 后半部分
    {
      left = mid + 1;
    }
  }
  return 0;
}
int main() {
  scanf("%d", &n);
  for (int k = 0; k < n; k++) {
    scanf("%d", &s[k]);
    // cin>>s[k];
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int nn;
    // cin>>nn;
    scanf("%d", &nn);
    if (BinarySearch(nn)) {
      cnt++;
      // cout<<nn<<endl;
    }
  }
  cout << cnt << endl;
  return 0;
}

// 含有标记的线性搜索可以将算法效率提高常数倍
// for(int i=0;i<n;i++)
// s[n]==key;while(s[i]!=key)i++;if(i!=n)
// 区别在于主循环中比较运算的次数
#include <cstdio>
#include <iostream>
using namespace std;
int s[100005];
int cnt, n;
/*void LinearSearch(int s[],int num)
{
        for(int i=0;i<n;i++)
        {
                if(s[i]==num)
                {
                        cnt++;
                        break;
                }
        }
}*/
int BinarySearch(int key) {
  int left = 0;
  int right = n;
  while (left < right) {
    int mid = (left + right) / 2;
    if (s[mid] == key) {
      // cout<<"1"<<endl;
      return 1;
    } else if (key < s[mid]) // 前半部分
    {
      right = mid;
    } else // 后半部分
    {
      left = mid + 1;
    }
  }
  return 0;
}
int main() {
  scanf("%d", &n);
  for (int k = 0; k < n; k++) {
    scanf("%d", &s[k]);
    // cin>>s[k];
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int nn;
    // cin>>nn;
    scanf("%d", &nn);
    if (BinarySearch(nn)) {
      cnt++;
      // cout<<nn<<endl;
    }
  }
  cout << cnt << endl;
  return 0;
}


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

// returns the index of the element which value equals to key.
// if no elements matched, it returns -1.
int search(const vector<int> &x, int key) {
  int left = 0, right = x.size();
  while (left < right) {
    int mid = (left + right) / 2;
    if (x[mid] == key) {
      return mid;
    } else if (key < x[mid]) {
      right = mid;
    } else if (x[mid] < key) {
      left = mid + 1;
    }
  }
  return -1;
}

int main() {
  int n;
  cin >> n;
  vector<int> na(0, n);
  for (int i = 0; i < n; i++)
    cin >> na[i];
  int q;
  cin >> q;
  int t;
  int ans = 0;
  for (int i = 0; i < q; ++i) {
    cin >> t;
    ans += search(na, t) >= 0 ? 1 : 0;
  }
  cout << ans << endl;
  return 0;
}

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

// returns the index of the element which value equals to key.
// if no elements matched, it returns -1.
int search(const vector<int> &x, int key) {
  int left = 0, right = x.size();
  while (left < right) {
    int mid = (left + right) / 2;
    if (x[mid] == key) {
      return mid;
    } else if (key < x[mid]) {
      right = mid;
    } else if (x[mid] < key) {
      left = mid + 1;
    }
  }
  return -1;
}

int main() {
  int n;
  cin >> n;
  vector<int> na(n, 0);
  for (int i = 0; i < n; i++)
    cin >> na[i];
  int q;
  cin >> q;
  int t;
  int ans = 0;
  for (int i = 0; i < q; ++i) {
    cin >> t;
    ans += search(na, t) >= 0 ? 1 : 0;
  }
  cout << ans << endl;
  return 0;
}


#include <iostream>

using namespace std;

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

  int n, q, t, count = 0;
  int left = 0, right = n, center;
  int S[100000];

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

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

  cout << count << endl;

  return 0;
}

#include <iostream>

using namespace std;

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

  int n, q, t, count = 0;
  int left, right, center;
  int S[100000];

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

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

  cout << count << endl;

  return 0;
}


#include <iostream>

using namespace std;

int b[1000000010];

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

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

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

int main() {
  ios::sync_with_stdio(false);
  int tmp1, tmp2, cnt = 0;
  cin >> tmp1;
  int lis[tmp1];
  for (int i = 0; i < tmp1; i++) {
    cin >> lis[i];
  }
  cin >> tmp2;
  int key[tmp2];
  for (int i = 0; i < tmp2; i++) {
    cin >> key[i];
    if (*lower_bound(lis, lis + tmp1, key[i]) == key[i]) {
      cnt++;
    }
  }
  cout << cnt << endl;
}


#include <iostream>
using namespace std;

// #include <stdio.h>
// #include <algorithm>
// #include <string>
#include <vector>

/********
 *   ?????¢??¢?´¢ Linear Search
 *********/

/*
int linearSearch(int strS int strT, int n )
{
        int key;

        for(int i =0 ; i < n; i++){
                if(strS[i] == key){
                        return i;
                }
        }
        return NOT_FOUND;
}
*/

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

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

  int q;
  cin >> q;
  vector<int> strT;
  strT.resize(q);

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

  int count = 0;
  for (int j = 0; j < q; j++) {
    for (int i = 0; i < n; i++) {
      if (strT[j] == strS[i]) {
        count++;
        break;
      }
    }
  }
  cout << count << endl;

  return 0;
}

#include <iostream>
using namespace std;

#include <algorithm>
#include <vector>
/********
 *	????????¢?´¢ Binary Search
 *********/

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

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

  int q;
  cin >> q;
  vector<int> strT;
  strT.resize(q);

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

  int count = 0;
  for (int j = 0; j < q; j++) {
    bool result = binary_search(strS.begin(), strS.end(), strT[j]);
    if (result)
      count++;
  }

  /*	int left  = 0;	//strS[0];
          int right = n;	//strS[(n-1)];
          int middle= (right + left)/2;

          for(int j = 0; j<q ; j++){
                  if( strS[(middle)] < middle ){
                          left = middle;
                                  if(strT[j] == strS[i]){
                                          count++;
                                          break;
                                  }
                          }
                  } else if( strS[middle] > middle){
                          for(int i =(n/2); i == 0; i--){
                                  if(strT[j] == strS[i]){
                                          count++;
                                          break;
                                  }
                          }
                  }
          }
  */
  cout << count << endl;

  return 0;
}


#include <iostream>

using namespace std;
int A[200000], n;

int binary_searcher(int key) {
  int mid;
  int left = 0;
  int right = n - 1;
  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, sum = 0;
  int key;
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> A[i];
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> key;
    if (binary_searcher(key))
      sum++;
  }
  cout << sum << endl;
  return 0;
}

#include <iostream>

using namespace std;
int A[200000], n;

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

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


#include <cstdio>

bool binSearch(int x, int array[], int first, int last) {
  int mid = (first + last) / 2;
  bool ret = false;
  if (array[mid] == x) {
    ret = true;
  } else {
    if (first == last) {
      ret = false;
    } else {
      if (array[mid] > x) {
        ret = binSearch(x, array, first, mid - 1);
      } else {
        ret = binSearch(x, array, mid + 1, last);
      }
    }
  }
  return ret;
}

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

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

  scanf("%d", &q);
  int x, sum = 0;
  for (int i = 0; i < q; i++) {
    scanf("%d", &x);
    if (binSearch(x, S, 0, n - 1)) {
      sum += 1;
    }
  }
  printf("%d\\n", sum);
  return 0;
}

#include <cstdio>

bool binSearch(int x, int array[], int first, int last) {
  int mid = (first + last) / 2;
  bool ret = false;
  if (array[mid] == x) {
    ret = true;
  } else {
    if (first >= last) {
      ret = false;
    } else {
      if (x < array[mid]) {
        ret = binSearch(x, array, first, mid - 1);
      } else {
        ret = binSearch(x, array, mid + 1, last);
      }
    }
  }
  return ret;
}

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

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

  scanf("%d", &q);
  int x, sum = 0;
  for (int i = 0; i < q; i++) {
    scanf("%d", &x);
    if (binSearch(x, S, 0, n - 1)) {
      sum += 1;
    }
  }
  printf("%d\\n", sum);
  return 0;
}


#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
bool flag[1000000000];
signed main() {
  int n, m;
  cin >> n;
  int s[100000], t[100000];
  rep(i, n) cin >> s[i];
  cin >> m;
  int cnt = 0;
  rep(i, m) cin >> t[i];
  rep(i, n) {
    rep(j, m) {
      if (s[i] == t[j] && flag[s[i]] == false) {
        cnt++;
        flag[s[i]] = true;
        break;
      }
    }
  }
  cout << cnt << endl;
}

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
int s[1000000];
int n;
bool search(int x) {
  int left = 0;
  int right = n;
  int mid;
  while (left < right) {
    mid = (left + right) / 2;
    if (x == s[mid])
      return 1;
    if (x > s[mid])
      left = mid + 1;
    else if (x < s[mid])
      right = mid;
  }
  return 0;
}
int main() {
  int m, cnt = 0;
  int t[1000000];
  cin >> n;
  rep(i, n) cin >> s[i];
  cin >> m;
  rep(i, m) cin >> t[i];
  sort(s, s + n);
  sort(t, t + m);
  rep(i, m) {
    int x = t[i];
    if (search(x))
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}


#include <bits/stdc++.h>
#include <ctype.h>
#include <math.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for (int i = 0; i < n; i++)
struct omt {
  omt() {
    ios::sync_with_stdio(false);
    cin.tie(0);
  }
} star;

int main() {
  int n, q;
  cin >> n;
  vector<int> S(n);
  for (auto &x : S)
    cin >> x;
  cin >> q;
  vector<int> T(q);
  for (auto &x : T)
    cin >> x;

  int cnt = 0;
  REP(i, q) {
    REP(j, n) {
      if (T[i] == S[j]) {
        cnt++;
        break;
      }
    }
  }
  cout << cnt << endl;

  return 0;
}

#include <bits/stdc++.h>
#include <ctype.h>
#include <math.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for (int i = 0; i < n; i++)
struct omt {
  omt() {
    ios::sync_with_stdio(false);
    cin.tie(0);
  }
} star;

bool binary_search(int n, int t, vector<int> S) {
  int l = 0, r = n;
  while (l < r) {
    int mid = (l + r) / 2;
    if (S[mid] == t)
      return true;
    else if (t < S[mid])
      r = mid;
    else
      l = mid + 1;
  }
  return false;
}

int main() {
  int n, q;
  cin >> n;
  vector<int> S(n);
  for (auto &x : S)
    cin >> x;
  cin >> q;
  vector<int> T(q);
  for (auto &x : T)
    cin >> x;

  int cnt = 0;
  REP(i, q) {
    if (binary_search(n, T[i], S))
      cnt++;
  }
  cout << cnt << endl;

  return 0;
}


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

int n, S[10000 + 1];

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

  while (left <= right) {
    mid = (left + right) / 2;
    // printf("L, R, M, S[mid]: %d %d %d %d\\n", left, right, mid, S[mid]);
    if (key == S[mid])
      return true;
    else if (key < S[mid])
      right = mid - 1;
    else
      left = mid + 1;
  }
  return false;
}

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

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

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

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

  return 0;
}

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

int n, S[100000 + 1];

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

  while (left <= right) {
    mid = (left + right) / 2;
    // printf("L, R, M, S[mid]: %d %d %d %d\\n", left, right, mid, S[mid]);
    if (key == S[mid])
      return true;
    else if (key < S[mid])
      right = mid - 1;
    else
      left = mid + 1;
  }
  return false;
}

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

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

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

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

  return 0;
}


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

int main() {
  int n, q;
  cin >> n;
  vector<int> na(n, 0);
  for (int i = 0; i < n; ++i)
    scanf("%d", &na[i]);
  cin >> q;
  vector<int> qa(q, 0);
  for (int i = 0; i < q; ++i)
    scanf("%d", &qa[i]);

  // linear search
  vector<int> ans;
  for (int i = 0; i < q; ++i) {
    for (int j = 0; j < n; ++j) {
      if (qa[i] == na[j]) {
        ans.push_back(qa[i]);
        break;
      }
    }
  }
  cout << ans.size() << endl;
  /*
  for(int i=0;i<ans.size();++i){
          if(i>0) cout << " ";
          cout << ans[i];
  }
  cout << endl;
  */
  return 0;
}

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

using namespace std;

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

int main() {
  int n;
  cin >> n;
  vector<int> na(n);
  for (int i = 0; i < n; ++i)
    scanf("%d", &na[i]);
  int q;
  cin >> q;
  int sum = 0;
  for (int i = 0; i < q; ++i) {
    int t;
    cin >> t;
    sum += search(na, t) ? 1 : 0;
  }
  cout << sum << endl;
  return 0;
}


#include <algorithm>
#include <cmath>
#include <iostream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

int binary_search(vector<int> S, vector<int> T) {
  // S???sort??????
  int cnt = 0;

  for (int i = 0; i < T.size(); i++) {
    int left = 0;
    int right = T.size();
    int mid = (left + right) / 2;
    while (left < right) {
      if (S[mid] == T[i]) {
        cnt++;
        break;
      }

      if (S[mid] < T[i]) {
        left = mid + 1;

      } else {
        right = mid;
      }
    }
  }
  return cnt;
}

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

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

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

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

  int res = binary_search(S, T);
  cout << res << endl;
}

#include <algorithm>
#include <cmath>
#include <iostream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

int binary_search(vector<int> S, vector<int> T) {
  // S???sort??????
  int cnt = 0;

  for (int i = 0; i < T.size(); i++) {
    int left = 0;
    int right = S.size();
    int mid = (left + right) / 2;
    while (left < right) {
      mid = (left + right) / 2;
      // cout << "left, right" << left << ", " << right << endl;
      if (S[mid] == T[i]) {
        cnt++;
        break;
      }

      if (S[mid] < T[i]) {
        left = mid + 1;

      } else {
        right = mid;
      }
    }
    // cout << "i: " << i << endl;
  }
  return cnt;
}

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

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

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

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

  int res = binary_search(S, T);
  cout << res << endl;
}


#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int a[10010];

int main() {
  int n, q, op;
  memset(a, 0, sizeof(a));
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &op);
    a[op]++;
  }
  scanf("%d", &q);
  int ans = 0;
  for (int i = 0; i < q; i++) {
    scanf("%d", &op);
    if (a[op] != 0) {
      ans++;
    }
  }
  printf("%d\\n", ans);
}

#include <cstdio>
#include <cstring>
#include <iostream>
#include <set>
using namespace std;
int a[10010];
set<int> s;

int main() {
  int n, q, op, ans = 0;
  memset(a, 0, sizeof(a));
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &op);
    s.insert(op);
  }
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d", &op);
    ans += s.count(op);
  }
  printf("%d\\n", ans);
}


#include <iostream>

using namespace std;

int main() {
  int cnt = 0;
  int x;
  cin >> x;
  long s[x];
  for (int i = 0; i < x; i++)
    cin >> s[i];
  int y;
  cin >> y;
  long t[y];
  for (int j = 0; j < y; j++) {
    cin >> t[j];
    int left = 0;
    int right = x - 1;
    while (1) {
      if (t[j] == s[(left + right) / 2]) {
        cnt++;
        break;
      }
      if (left == right)
        break;
      if (t[j] > s[(left + right) / 2])
        left = (left + right) / 2 + 1;
      if (t[j] < s[(left + right) / 2])
        right = (left + right) / 2 - 1;
    }
  }
  cout << cnt << endl;
}

#include <iostream>

using namespace std;

int main() {
  int cnt = 0;
  int x;
  cin >> x;
  long s[x];
  for (int i = 0; i < x; i++)
    cin >> s[i];
  int y;
  cin >> y;
  long t[y];
  for (int j = 0; j < y; j++) {
    cin >> t[j];
    int left = 0;
    int right = x - 1;
    while (left <= right) {
      if (t[j] == s[(left + right) / 2]) {
        cnt++;
        break;
      }
      if (t[j] > s[(left + right) / 2])
        left = (left + right) / 2 + 1;
      if (t[j] < s[(left + right) / 2])
        right = (left + right) / 2 - 1;
    }
  }
  cout << cnt << endl;
}


#include <cstdio>
#define S_MAX 1000000

bool binarySearch(int S[], int s, int e, int t) {
  int half = (s + e) / 2;
  int half_value = S[half];
  bool found = false;
  if (half_value == t) {
    return true;
  } else if (half_value < t) {
    return binarySearch(S, half, e, t);
  } else if (t < half_value) {
    return binarySearch(S, s, half, t);
  }
  return false;
}

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

  int q;
  scanf("%d", &q);
  int count = 0;
  for (int j = 0; j < q; j++) {
    int t;
    scanf("%d", &t);
    if (S[n - 1] < t)
      continue;
    if (binarySearch(S, 0, n - 1, t))
      count++;
  }

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

  return 0;
}

#include <cstdio>
#define S_MAX 1000000

bool binarySearch(int S[], int s, int e, int t) {
  if (e < s)
    return false;
  int half = (s + e) / 2;
  int half_value = S[half];
  if (half_value == t) {
    return true;
  } else if (half_value < t) {
    return binarySearch(S, half + 1, e, t);
  } else if (t < half_value) {
    return binarySearch(S, s, half - 1, t);
  }
  return false;
}

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

  int q;
  scanf("%d", &q);
  int count = 0;
  for (int j = 0; j < q; j++) {
    int t;
    scanf("%d", &t);
    if (S[n - 1] < t)
      continue;
    if (t < S[0])
      continue;
    if (binarySearch(S, 0, n - 1, t))
      count++;
  }

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

  return 0;
}


#include <iostream>
#include <vector>

typedef unsigned uint;

bool is_exist_bin_search(uint v, std::vector<uint> s) {
  uint min = 0, max = s.size() - 1;
  while (min < max) {
    uint mid = (min + max) / 2;
    uint v_mid = s[mid];
    if (v_mid == v)
      return true;

    if (v_mid >= v)
      max = mid;
    else
      min = mid;
  }
  return false;
}

unsigned count(std::vector<uint> s, std::vector<uint> t) {
  uint n = 0;
  for (uint i = 0; i < t.size(); i++) {
    if (is_exist_bin_search(t[i], s))
      n++;
  }
  return n;
}

int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);
  std::vector<uint> s, t;

  {
    uint n, buf;
    std::cin >> n;
    for (; n; n--) {
      std::cin >> buf;
      s.push_back(buf);
    }
  }

  {
    uint q, buf;
    std::cin >> q;
    for (; q; q--) {
      std::cin >> buf;
      t.push_back(buf);
    }
  }

  std::cout << count(s, t) << '\\n';
}

#include <iostream>
#include <vector>

typedef unsigned uint;

bool is_exist_bin_search(uint v, std::vector<uint> s) {
  uint min = 0, max = s.size();
  while (min < max) {
    uint mid = (min + max) / 2;
    uint v_mid = s[mid];
    if (v_mid == v)
      return true;

    if (v_mid >= v)
      max = mid;
    else
      min = mid + 1;
  }
  return false;
}

unsigned count(std::vector<uint> s, std::vector<uint> t) {
  uint n = 0;
  for (uint i = 0; i < t.size(); i++) {
    if (is_exist_bin_search(t[i], s))
      n++;
  }
  return n;
}

int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);
  std::vector<uint> s, t;

  {
    uint n, buf;
    std::cin >> n;
    for (; n; n--) {
      std::cin >> buf;
      s.push_back(buf);
    }
  }

  {
    uint q, buf;
    std::cin >> q;
    for (; q; q--) {
      std::cin >> buf;
      t.push_back(buf);
    }
  }

  std::cout << count(s, t) << '\\n';
}


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

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

void BubbleSort(vector<int> &);
int BinarySearch(const vector<int> &, const vector<int> &);
void WriteVector(const vector<int> &);

void WriteVector(const vector<int> &v) {
  for (int i = 0; i < v.size(); i++) {
    cout << v.at(i) << "\\n";
  }
}

void BubbleSort(vector<int> &v) {
  bool changed = true;
  while (changed) {
    changed = false;
    for (int i = v.size() - 1; 1 <= i; i--) {
      if (v.at(i) < v.at(i - 1)) {
        int tmp = v.at(i - 1);
        v.at(i - 1) = v.at(i);
        v.at(i) = tmp;
        changed = true;
      }
    }
  }
  cout << "sorted"
       << "\\n";
  WriteVector(v);
}

int BinarySearch(const vector<int> &unsorted_s, const vector<int> &sorted_t) {

  int n_common = 0;

  for (int i = 0; i < unsorted_s.size(); i++) {
    int begin = 0;
    int end = sorted_t.size();
    // cout << "searching: " << unsorted_s.at(i) << "\\n";
    while (begin < end) {
      int mid = (begin + end) / 2;

      if (sorted_t.at(mid) == unsorted_s.at(i)) {
        n_common = n_common + 1;
        // cout << "found: " << unsorted_s.at(i) << "\\n";
        break;
      } else if (sorted_t.at(mid) < unsorted_s.at(i)) {
        // cout << "case1:  begin: " << begin << ", mid: " << mid << ", end: "
        //	 << end << ", unsorted_s.at(i): " << unsorted_s.at(i) << "\\n";
        begin = mid + 1;
      } else { // sorted_t.at(mid) > unsorted_s.at(i)
        // cout << "case2:  begin: " << begin << ", mid: " << mid << ", end: "
        //	 << end << ", unsorted_s.at(i): " << unsorted_s.at(i) << "\\n";
        end = mid;
      }
    }
  }
  return n_common;
}

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

  int m;
  vector<int> t;
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    scanf("%d", input);
    t.push_back(input);
  }

  // BubbleSort(t);

  int n_common = 0;
  n_common = BinarySearch(t, s);

  cout << n_common << "\\n";

  return 0;
}

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

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

void BubbleSort(vector<int> &);
int BinarySearch(const vector<int> &, const vector<int> &);
void WriteVector(const vector<int> &);

void WriteVector(const vector<int> &v) {
  for (int i = 0; i < v.size(); i++) {
    cout << v.at(i) << "\\n";
  }
}

void BubbleSort(vector<int> &v) {
  bool changed = true;
  while (changed) {
    changed = false;
    for (int i = v.size() - 1; 1 <= i; i--) {
      if (v.at(i) < v.at(i - 1)) {
        int tmp = v.at(i - 1);
        v.at(i - 1) = v.at(i);
        v.at(i) = tmp;
        changed = true;
      }
    }
  }
  cout << "sorted"
       << "\\n";
  WriteVector(v);
}

int BinarySearch(const vector<int> &unsorted_s, const vector<int> &sorted_t) {

  int n_common = 0;

  for (int i = 0; i < unsorted_s.size(); i++) {
    int begin = 0;
    int end = sorted_t.size();
    // cout << "searching: " << unsorted_s.at(i) << "\\n";
    while (begin < end) {
      int mid = (begin + end) / 2;

      if (sorted_t.at(mid) == unsorted_s.at(i)) {
        n_common = n_common + 1;
        // cout << "found: " << unsorted_s.at(i) << "\\n";
        break;
      } else if (sorted_t.at(mid) < unsorted_s.at(i)) {
        // cout << "case1:  begin: " << begin << ", mid: " << mid << ", end: "
        //	 << end << ", unsorted_s.at(i): " << unsorted_s.at(i) << "\\n";
        begin = mid + 1;
      } else { // sorted_t.at(mid) > unsorted_s.at(i)
        // cout << "case2:  begin: " << begin << ", mid: " << mid << ", end: "
        //	 << end << ", unsorted_s.at(i): " << unsorted_s.at(i) << "\\n";
        end = mid;
      }
    }
  }
  return n_common;
}

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

  int m;
  vector<int> t;
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    int input;
    scanf("%d", &input);
    t.push_back(input);
  }

  // BubbleSort(t);

  int n_common = 0;
  n_common = BinarySearch(t, s);

  // cout << n_common << "\\n";
  printf("%d\\n", n_common);

  return 0;
}


#include <iostream>

#include <algorithm>
#include <cmath>

using namespace std;

int S[10010];
int s, q;

bool binarySearch(int A[], int key) {
  int left = 0;
  int right = s - 1;
  int mid;

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

int main() {

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

  int count = 0;
  int temp;

  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> temp;
    if (binarySearch(S, temp)) {
      count++;
    }
  }

  cout << count << endl;

  return 0;
}

#include <iostream>

#include <algorithm>
#include <cmath>

using namespace std;

int S[100100];
int s, q;

bool binarySearch(int A[], int key) {
  int left = 0;
  int right = s - 1;
  int mid;

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

int main() {

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

  int count = 0;
  int temp;

  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> temp;
    if (binarySearch(S, temp)) {
      count++;
    }
  }

  cout << count << endl;

  return 0;
}


#include <iostream>

int n, S[100000];

int search(int T) {
  int l = 0, r = n;
  int mid;

  while (l < r) {
    mid = (l + r) / 2;
    if (T == S[mid])
      return 1;
    if (T > S[mid])
      l = mid + 1;
    else if (T < S[mid])
      r = mid;
  }
  return 0;
}

int main() {
  int i, q;
  int T[5000];
  int count = 0;

  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];
    if (search(T[i])) {
      count++;
    }
  }
  std::cout << count << std::endl;
  return 0;
}

#include <iostream>

int n, S[100000];

int search(int T) {
  int l = 0, r = n;
  int mid;

  while (l < r) {
    mid = (l + r) / 2;
    if (T == S[mid])
      return 1;
    if (T > S[mid])
      l = mid + 1;
    else if (T < S[mid])
      r = mid;
  }
  return 0;
}

int main() {
  int i, q;
  int T[50000];
  int count = 0;

  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];
    if (search(T[i])) {
      count++;
    }
  }
  std::cout << count << std::endl;
  return 0;
}


#include <iostream>
using namespace std;

int main() {
  int sn, tn, t, l, r, m, c = 0;
  cin >> sn;
  int *s = new int[sn];
  for (int i = 0; i < sn; i++)
    cin >> s[i];
  cin >> tn;
  for (int i = 0; i < tn; i++) {
    cin >> t;
    l = 0;
    r = sn - 1;
    while (l < r) {
      m = (l + r) / 2;
      if (s[m] == t) {
        c++;
        break;
      } else if (t < s[m])
        r = m + 1;
      else
        l = m - 1;
    }
  }
  cout << c << endl;
  return 0;
}

#include <iostream>
using namespace std;

int main() {
  int sn, tn, t, l, r, m, c = 0;
  cin >> sn;
  int *s = new int[sn];
  for (int i = 0; i < sn; i++)
    cin >> s[i];
  cin >> tn;
  for (int i = 0; i < tn; i++) {
    cin >> t;
    l = 0;
    r = sn;
    while (l < r) {
      m = (l + r) / 2;
      if (s[m] == t) {
        c++;
        break;
      } else if (t < s[m])
        r = m;
      else
        l = m + 1;
    }
  }
  cout << c << endl;
  return 0;
}


#include <stdio.h>

using namespace std;

int S[10001], n, q;

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

      return -1;
  */

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

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

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

#include <stdio.h>

int binarysearch(int q[], int key, int n) {
  int left = 0;
  int right = n;

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

int main() {
  int n, a;
  scanf("%d", &n);
  int s[100000];

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

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

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


#include <iostream>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

void read_separated_string(vector<int> &v, string str) {
  istringstream istr(str);
  string tmp;
  while (getline(istr, tmp, ' ')) {
    v.push_back(stoi(tmp));
  }
}

int binary_search(int n, const vector<int> &v) {
  if (v.size() == 1) {
    if (v[0] == n) {
      return 1;
    } else {
      return 0;
    }
  }
  int mid = (int)(v.size() / 2);
  if (v[mid] == n) {
    return 1;
  } else if (v[mid] > n) {
    vector<int> half;
    for (int i = 0; i < mid; ++i) {
      half.push_back(v[i]);
    }
    return binary_search(n, half);
  } else {
    vector<int> half;
    for (int i = mid; i < v.size(); ++i) {
      half.push_back(v[i]);
    }
    return binary_search(n, half);
  }
}

int main() {
  int N, Q;
  vector<int> n;
  vector<int> q;
  string str;
  cin >> N;
  cin.ignore();
  getline(cin, str);
  read_separated_string(n, str);
  cin >> Q;
  cin.ignore();
  getline(cin, str);
  read_separated_string(q, str);
  int count = 0;
  for (auto i : q) {
    count += binary_search(i, n);
  }
  cout << count << endl;
}

#include <iostream>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

void read_separated_string(vector<int> &v, string str) {
  istringstream istr(str);
  string tmp;
  while (getline(istr, tmp, ' ')) {
    v.push_back(stoi(tmp));
  }
}

int binary_search(const vector<int> &v, int first, int last, int key) {
  int middle = (int)((first + last) / 2);
  if (first > last) {
    return 0;
  } else if (key == v[middle]) {
    return 1;
  } else if (key < v[middle]) {
    return binary_search(v, first, middle - 1, key);
  } else {
    return binary_search(v, middle + 1, last, key);
  }
}

int main() {
  int N, Q;
  vector<int> n;
  vector<int> q;
  string str;

  cin >> N;
  cin.ignore();
  getline(cin, str);
  read_separated_string(n, str);
  cin >> Q;
  cin.ignore();
  getline(cin, str);
  read_separated_string(q, str);

  int count = 0;
  for (int i = 0; i < q.size(); ++i) {
    count += binary_search(n, 0, n.size() - 1, q[i]);
  }
  cout << count << endl;
}


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

int main() {
  int a, b[100000], c, d[50000], e = 0;
  cin >> a;
  for (int i = 0; i < a; i++) {
    cin >> b[i];
  }
  cin >> c;
  for (int i = 0; i < c; i++) {
    cin >> d[i];
  }
  for (int i = 0; i < c; i++) {
    for (int j = 0; j < a; j++) {
      if (b[j] == d[i]) {
        e += 1;
        break;
      }
    }
  }
  cout << e << endl;
  return 0;
}

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

int main() {
  int a, b[100000], c, d[50000], e, f, g = 0;
  cin >> a;
  for (int i = 0; i < a; i++) {
    cin >> b[i];
  }
  cin >> c;
  for (int i = 0; i < c; i++) {
    cin >> d[i];
  }
  for (int i = 0; i < c; i++) {
    e = 0;
    f = a;
    while (e < f) {
      if (d[i] == b[(e + f) / 2]) {
        g++;
        break;
      }
      if (d[i] < b[(e + f) / 2]) {
        f = (e + f) / 2;
        continue;
      } else if (d[i] > b[(e + f) / 2]) {
        e = (e + f) / 2 + 1;
        continue;
      }
    }
  }
  cout << g << endl;
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

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

  fill_n(S, 100000, 0);
  fill_n(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];
  }

  sort(S, S + n);

  for (int i = 0; i < q; i++) {
    for (int j = 0; j < n; j++) {
      if (T[i] < S[j])
        break;
      if (T[i] == S[j]) {
        cnt++;
        break;
      }
    }
  }
  cout << cnt << endl;
}

#include <bits/stdc++.h>

using namespace std;

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

  fill_n(S, 100000, 0);
  fill_n(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];
  }

  sort(S, S + n);

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


#include <iostream>
#include <vector>

using namespace std;

typedef vector<int> int_vec;

bool linear_search(const int_vec &v, int n) {
  for (int_vec::const_iterator it = v.begin(); it != v.end(); ++it) {
    if (*it == n) {
      return true;
    }
  }
  return false;
}

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

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

  int c = 0;
  for (int_vec::iterator it = T.begin(); it != T.end(); ++it) {
    if (linear_search(S, *it))
      c++;
  }
  cout << c << endl;
}

#include <iostream>
#include <vector>

using namespace std;

typedef vector<int> int_vec;

bool linear_search(const int_vec &v, int n) {
  for (int_vec::const_iterator it = v.begin(); it != v.end(); ++it) {
    if (*it == n) {
      return true;
    }
  }
  return false;
}

bool binary_search(int_vec::iterator begin, int_vec::iterator end, int n) {
  while (begin < end) {
    int_vec::iterator mid = begin + ((end - begin) / 2);
    if (*mid == n)
      return true;
    else if (n < *mid)
      end = mid;
    else
      begin = mid + 1;
  }
  return false;
}

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

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

  int c = 0;
  for (int_vec::iterator it = T.begin(); it != T.end(); ++it) {
    if (binary_search(S.begin(), S.end(), *it))
      c++;
  }
  cout << c << endl;
}


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

int main() {
  int n[10000], q[500], x, y, s = 0;
  int l, r, m;
  cin >> x;
  for (int i = 0; i < x; i++)
    cin >> n[i];
  cin >> y;
  for (int i = 0; i < y; i++) {
    cin >> q[i];
    l = 0;
    r = x;
    while (l <= r) {
      m = (l + r) / 2;
      if (n[m] < q[i])
        l = m + 1;
      if (n[m] > q[i])
        r = m;
      else if (q[i] == n[m]) {
        s++;
        break;
      }
    }
  }

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

#include <iostream>

using namespace std;

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

  int n, q, t, count = 0;
  int left, right, center;
  int S[100000];

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

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

  cout << count << endl;

  return 0;
}


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

int A[10000], n;

int Search(int key) {
  int l = 0;
  int r = n;
  int m;
  while (l < r) {
    m = (l + r) / 2;
    if (A[m] < key)
      l = m + 1;
    if (A[m] > key)
      r = m;
    else if (A[m] == key)
      return 1;
  }

  return 0;
}

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

    if (Search(k))
      s++;
  }

  cout << s << "\\n";
  return 0;
}

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

int A[100000], n;

int Search(int key) {
  int l = 0;
  int r = n;
  int m;
  while (l < r) {
    m = (l + r) / 2;
    if (A[m] < key)
      l = m + 1;
    if (A[m] > key)
      r = m;
    else if (A[m] == key)
      return 1;
  }

  return 0;
}

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

    if (Search(k))
      s++;
  }

  cout << s << "\\n";
  return 0;
}


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

bool twodiv_search(const int n, int S[], const int key) {
  int start = 0;
  int end = n - 1;
  int mid;
  bool res = false;

  while (end - start > 0) {
    mid = (start + end) / 2;
    if (S[mid] < key) {
      start = mid;
    } else if (S[mid] > key) {
      end = mid;
    } else {
      res = true;
      break;
    }
  }
  return res;
}

int main(void) {

  int n;
  int q;
  int key;
  int count = 0;

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

  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d", &key);
    count += twodiv_search(n, S, key);
  }
  printf("%d\\n", count);

  return 0;
}

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

bool twodiv_search(const int n, int S[], const int key) {
  int start = 0;
  int end = n;
  int mid;
  bool res = false;

  while (end - start > 0) {
    mid = (start + end) / 2;
    //        printf("s %d e %d mid %d S[mid] %d\\n", start, end, mid, S[mid]);
    if (S[mid] < key) {
      if (start == mid)
        break;
      start = mid;
    } else if (S[mid] > key) {
      if (end == mid)
        break;
      end = mid;
    } else {
      res = true;
      break;
    }
  }
  return res;
}

int main(void) {

  int n;
  int q;
  int key;
  int count = 0;

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

  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d", &key);
    count += twodiv_search(n, S, key);
  }
  printf("%d\\n", count);

  return 0;
}


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

using namespace std;

int main() {
  int ans = 0;
  int n, q;
  vector<int> s;
  vector<int> t;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int input;
    cin >> input;
    s.push_back(input);
  }
  cin >> q;
  for (int i = 0; i < q; i++) {
    int input;
    cin >> input;
    t.push_back(input);
  }
  sort(t.begin(), t.end());

  int prev = 0;
  for (int i = 0; i < q; i++) {
    for (int j = prev + 1; j < n; j++) {
      if (t[i] == s[j]) {
        ans++;
        break;
        prev = j;
      }
    }
  }
  cout << ans << endl;
}

#include <iostream>
#include <vector>

using namespace std;

int main() {
  int ans = 0;
  int n, q;
  vector<int> s;
  vector<int> t;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int input;
    cin >> input;
    s.push_back(input);
  }
  cin >> q;
  for (int i = 0; i < q; i++) {
    int input;
    cin >> input;
    t.push_back(input);
  }

  //??蔵?卒蔵?????????:t[i]
  for (int i = 0; i < q; i++) {
    int low = 0;  //???????????????
    int high = n; //???????????????
    int mid;
    while (low <= high) {
      mid = (low + high) / 2;
      if (s[mid] == t[i]) {
        ans++;
        break;
      } else if (s[mid] < t[i]) {
        low = mid + 1;
      } else {
        high = mid - 1;
      }
    }
  }
  cout << ans << endl;
}


#include <cstdio>

#define MAX_N 100000
#define MAX_Q 50000

using namespace std;

int S[MAX_N + 5], T[MAX_Q + 5];

bool searchS(int x, int length) {
  int left = 0, right = length - 1;
  while (left < right) {
    int mid = (left + right) / 2;
    if (S[mid] == x) {
      return true;
    } else if (S[mid] < x) {
      left = mid;
    } else if (S[mid] > x) {
      right = mid;
    }
  }
  return false;
}

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

  return 0;
}

#include <cstdio>

#define MAX_N 100000
#define MAX_Q 50000

using namespace std;

int S[MAX_N + 5], T[MAX_Q + 5];

bool searchS(int x, int length) {
  int left = 0, right = length, mid;
  while (left < right) {
    mid = (left + right) / 2;
    if (S[mid] == x) {
      return true;
    } else if (S[mid] < x) {
      left = mid + 1;
    } else if (S[mid] > x) {
      right = mid;
    }
  }
  return false;
}

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

  return 0;
}


#include <iostream>
#include <string>
#include <vector>

using namespace std;

bool binSearch(int *s, int n, int target) {
  int lo = 0;
  int hi = n - 1;
  while (lo <= hi) {
    int mid = lo + (hi - lo) / 2;
    if (s[mid] == target)
      return true;
    else if (target > s[mid])
      lo = mid + 1;
    else
      hi = mid - 1;
  }
  return false;
}

int main() {
  int val, n, q;
  int s[10000], t[500];

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

  int count = 0;
  cin >> q;
  while (q--) {
    cin >> val;
    if (binSearch(s, n, val))
      count++;
  }

  cout << count << endl;
  return 0;
}

#include <iostream>
#include <string>
#include <vector>

using namespace std;

bool binSearch(int *s, int n, int target) {
  int lo = 0;
  int hi = n - 1;
  while (lo <= hi) {
    int mid = lo + (hi - lo) / 2;
    if (s[mid] == target)
      return true;
    else if (target > s[mid])
      lo = mid + 1;
    else
      hi = mid - 1;
  }
  return false;
}

int main() {
  int val, n, q;
  int s[100000], t[50000];

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

  int count = 0;
  cin >> q;
  while (q--) {
    cin >> val;
    if (binSearch(s, n, val))
      count++;
  }

  cout << count << endl;
  return 0;
}


#include <cstdio>

int main() {
  int n, m, ans = 0;

  int A[100001];
  scanf("%d", &n);

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

  scanf("%d", &m);

  for (int i = 0; i < m; i++) {
    int a;
    scanf("%d", &a);
    int j = 0;
    while (A[j] != a)
      j++;
    if (j < n)
      ans++;
  }
  printf("%d\\n", ans);
  return 0;
}

#include <cstdio>

int main() {
  int n, m, ans = 0;

  int A[100001];
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%d", A + i);
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    int a;
    scanf("%d", &a);
    int j = 0;
    A[n] = a;
    while (A[j] != a)
      j++;
    if (j < n)
      ans++;
  }
  printf("%d\\n", ans);
  return 0;
}


#include <iostream>
using namespace std;

bool binSearch(int A[], int target, int size) {
  int left = 0, right = size - 1, mid;
  while (left <= right) {
    mid = (left + right) / 2;
    // cout <<  "left : " << left << ", right : " << right << ", mid : " << mid
    // << endl;
    if (A[mid] == target) {
      // cout << target << " found." << endl;
      return true;
    } else {
      if (A[mid] < target)
        left = mid + 1;
      else
        right = mid;
    }
  }
  return false;
}

int main() {
  int size, query, queryNum, count = 0;

  cin >> size;
  int *A = new int[size];
  for (int i = 0; i < size; i++)
    scanf("%d", &A[i]);

  cin >> queryNum;
  for (int i = 0; i < queryNum; i++) {
    scanf("%d", &query);
    if (binSearch(A, query, size))
      count++;
  }

  cout << count << endl;

  delete[] A;
}

#include <iostream>
using namespace std;

bool binSearch(int A[], int target, int size) {
  int left = 0, right = size, mid;
  while (left < right) {
    mid = (left + right) / 2;
    // cout <<  "left : " << left << ", right : " << right << ", mid : " << mid
    // << endl;
    if (A[mid] == target) {
      // cout << target << " found." << endl;
      return true;
    } else {
      if (A[mid] < target)
        left = mid + 1;
      else
        right = mid;
    }
  }
  return false;
}

int main() {
  int size, query, queryNum, count = 0;

  cin >> size;
  int *A = new int[size];
  for (int i = 0; i < size; i++)
    scanf("%d", &A[i]);

  cin >> queryNum;
  for (int i = 0; i < queryNum; i++) {
    scanf("%d", &query);
    if (binSearch(A, query, size))
      count++;
  }

  cout << count << endl;

  delete[] A;
}


#include <iostream>
using namespace std;

int main() {
  int tmp, t, n, m = 1, q, count = 0;
  bool s[1000000001] = {};

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

  cout << count << endl;

  return 0;
}

#include <iostream>
using namespace std;

int main() {
  int tmp, s[100000], t, n, m = 1, q, count = 0;

  cin >> n >> s[0];
  for (int i = 1; i < n; i++) {
    cin >> tmp;
    if (tmp > s[m - 1]) {
      s[m] = tmp;
      m++;
    }
  }
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> t;
    for (int j = 0; j < m; j++) {
      if (s[j] < t)
        continue;
      else if (s[j] == t) {
        count++;
        break;
      } else
        break;
    }
  }

  cout << count << endl;

  return 0;
}


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

int main() {
  int n, q, count, left, right, mid;
  cin >> n;
  int s[n];
  REP(i, n) { cin >> s[i]; }
  cin >> q;
  int t[q];
  REP(i, q) { cin >> t[i]; }

  count = 0;
  REP(i, q) {
    left = 0;
    right = n - 1;
    while (left < right) {
      mid = (left + right) / 2;
      if (s[mid] == t[i]) {
        count++;
      } else if (s[mid] > t[i]) {
        right = mid - 1;
      } else if (s[mid] < t[i]) {
        left = mid + 1;
      }
    }
  }
  cout << count << endl;
  return 0;
}

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

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

int main() {
  int n, q, count, left, right, mid;
  cin >> n;
  int s[n];
  REP(i, n) { cin >> s[i]; }
  cin >> q;
  int t[q];
  REP(i, q) { cin >> t[i]; }

  count = 0;
  REP(i, q) {
    if (binarySearch(t[i], n, s))
      count++;
  }

  cout << count << endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
  int n;
  cin >> n;
  int s[n];
  rep(i, 0, n) cin >> s[i];
  int q;
  cin >> q;
  int t[q];
  rep(i, 0, q) cin >> t[i];

  int ans = 0;
  rep(i, 0, q) {
    int left = 0;
    int right = n;
    while (left < right) {
      int mid = (left + right) / 2;
      if (t[i] == s[mid]) {
        ans++;
        break;
      } else if (t[i] < s[mid]) {
        right = mid;
      } else {
        left = mid;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
  int n;
  cin >> n;
  int s[n];
  rep(i, 0, n) cin >> s[i];
  int q;
  cin >> q;
  int t[q];
  rep(i, 0, q) cin >> t[i];

  int ans = 0;
  rep(i, 0, q) {
    int left = 0;
    int right = n - 1;
    while (left <= right) {
      int mid = (left + right) / 2;
      if (t[i] == s[mid]) {
        ans++;
        break;
      } else if (t[i] < s[mid]) {
        right = mid - 1;
      } else {
        left = mid + 1;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


#include <iostream>
using namespace std;

int main() {
  int m[1000000001] = {0}, a, b, cou;
  cin >> a;
  for (int i = 0; i < a; i++) {
    cin >> b;
    m[b] = 1;
  }
  cin >> b;
  cou = 0;
  for (int j = 0; j < b; j++) {
    cin >> a;
    cou += m[a];
  }
  cout << cou << endl;
  return 0;
}

#include <iostream>
using namespace std;
int s[100001];

int nibun(int k, int n) {
  int h, t;
  h = 0;
  t = n;
  while (h < t) {
    if (k == s[(h + t) / 2]) {
      return 1;
    } else if (k < s[(h + t) / 2])
      t = (h + t) / 2;
    else if (k > s[(h + t) / 2])
      h = (h + t) / 2 + 1;
  }
  return 0;
}

int main() {
  int n, q, t, h, k;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  cin >> q;
  for (int i = 0; i < q; i++) {
    h = 0;
    cin >> t;
    h = nibun(t, n);
    if (h == 1)
      k++;
  }
  cout << k << endl;
  return 0;
}


#include <algorithm>
#include <iostream>
#include <math.h> /* pow */
#include <stack>
#include <stdio.h> /* printf */
#include <stdlib.h>
#include <string>
#include <vector>

int linearSearch(std::vector<int> &list, std::vector<int> &seq) {
  int found = 0;
  for (int i = 0; i < seq.size(); i++) {
    int j = 0;
    while (j < list.size() && list[j] <= seq[i]) {
      if (list[j] == seq[i]) {
        j = list.size();
        found++;
      } else {
        j++;
      }
    }
  }
  return found;
}

int main(void) {
  int value;
  std::vector<int> list;
  int n;
  std::cin >> n;
  for (int i = 0; i < n; i++) {
    std::cin >> value;
    list.push_back(value);
  }
  std::vector<int> seq;
  int q;
  std::cin >> q;
  for (int j = 0; j < q; j++) {
    std::cin >> value;
    seq.push_back(value);
  }
  std::cout << linearSearch(list, seq) << std::endl;
  return 0;
}

#include <algorithm>
#include <iostream>
#include <math.h> /* pow */
#include <stack>
#include <stdio.h> /* printf */
#include <stdlib.h>
#include <string>
#include <vector>

bool binarySearch(std::vector<int> &list, int L, int R, int T) {
  if (L > R)
    return false;
  int m = floor((L + R) / 2);
  if (T < list[m]) {
    return binarySearch(list, L, m - 1, T);
  } else if (T > list[m]) {
    return binarySearch(list, m + 1, R, T);
  } else {
    return true;
  }
}

int linearSearch(std::vector<int> &list, std::vector<int> &seq) {
  int found = 0;
  for (int i = 0; i < seq.size(); i++) {
    if (binarySearch(list, 0, list.size() - 1, seq[i]))
      found++;
  }
  return found;
}

int main(void) {
  int value;
  std::vector<int> list;
  int n;
  std::cin >> n;
  for (int i = 0; i < n; i++) {
    std::cin >> value;
    list.push_back(value);
  }
  std::vector<int> seq;
  int q;
  std::cin >> q;
  for (int j = 0; j < q; j++) {
    std::cin >> value;
    seq.push_back(value);
  }
  std::cout << linearSearch(list, seq) << std::endl;
  return 0;
}


#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <string>
#include <typeinfo>
#include <vector>
#define _USE_MATH_DEFINES
#include <cmath>
#include <queue>
#include <stack>

using namespace std;

int main() {

  int n, q;
  cin >> n;
  vector<int> seq1(n);
  for (int i = 0; i < n; i++) {
    cin >> seq1[i];
  }
  cin >> q;
  vector<int> seq2(q);
  for (int i = 0; i < q; i++) {
    cin >> seq2[i];
  }

  // seq1内のかぶり数の削除
  // seq1はinputの段階で既にsort済
  vector<int>::iterator itr = seq1.begin();
  while (itr != seq1.end()) {
    if (*itr == *(itr + 1)) {
      seq1.erase(itr);
      itr--;
    }
    itr++;
  }
  // seq1内整数の最大値、最小値の取得(Binary Searchに使用)
  vector<int>::iterator itr1_min = seq1.begin();
  vector<int>::iterator itr1_max = seq1.end();
  itr1_max--;
  int min_in_seq1 = *itr1_min;
  int max_in_seq1 = *itr1_max;

  sort(seq2.begin(), seq2.end());
  vector<int>::iterator itr2 = seq2.begin();
  while (itr2 != seq2.end()) {
    if (*itr2 == *(itr2 + 1)) {
      seq2.erase(itr2);
      itr2--;
    }
    itr2++;
  }

  int both_num = 0;

  int size1 = seq1.size() - 1;
  int size2 = seq2.size();

  // すべてseq1のindex
  int index = size1;
  int index_max = size1;
  index /= 2;
  int index_mid = index;

  for (int i = 0; i < size2; i++) {
    int seq2_val = seq2[i];
    if (!(min_in_seq1 <= seq2_val && seq2_val <= max_in_seq1)) {
      continue;
    }
    // min <= size2[i] <= maxのときのループ処理
    // seq2_valは固定

    index = index_mid;

    while (true) {
      if (seq2_val < seq1[index]) {
        index /= 2;
        continue;
      } else if (seq1[index] < seq2_val) {

        index = index + (index_max - index) / 2;

        // どちらのindexもだめ
        // max_indexとmin_indexを取得して比較したほうが良い

        // 2->4->2->4->...
        // index = index + (index/2) + 1;

        // 3->1->1->1...
        // index = index + (index/2);
        continue;
      } else {
        both_num += 1;
        break;
      }
    }
  }

  cout << both_num << endl;

  return 0;
}

//

// g++ -std=c++11 abc145_c.cc && ./a.out
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

bool isContained(int needle, vector<int> &haystack, int min, int max) {
  int mid = (max + min) / 2;
  if (max - min <= 2) {
    return (needle == haystack[min]) || (needle == haystack[max]) ||
           (needle == haystack[mid]);
  }

  if (needle < haystack[mid]) {
    return isContained(needle, haystack, min, mid);
  } else if (needle > haystack[mid]) {
    return isContained(needle, haystack, mid, max);
  } else {
    return true;
  }
}

int main() {
  int n, q, i, j;
  cin >> n;

  // 重複あり
  vector<int> S(n);
  rep(i, n) cin >> S[i];
  sort(S.begin(), S.end());

  cin >> q;
  // すべて異なる
  vector<int> T(q);
  rep(i, q) cin >> T[i];

  int count = 0;
  rep(i, q) {
    int t = T[i];
    if (isContained(t, S, 0, S.size() - 1)) {
      // for debug
      // cout << t << " is contained" << endl;

      count++;
    }
  }
  cout << count << endl;

  return 0;
}


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

int Binary(int a[], int sizea, int b[], int sizeb) {
  int num = 0;
  int j = 0;
  int i = 0;
  do {
    if (i >= sizea || j >= sizeb) {
      break;
    }

    if (a[i] == b[j]) {
      num++;
      i++;
      j++;
    } else if (a[i] > b[j]) {
      j++;
      if (j >= sizeb) {
        j = sizeb - 1;
      }
    } else if (a[i] < b[j]) {
      i++;
      if (i >= sizea) {
        i = sizea - 1;
      }
    }
  } while (i <= sizea || j <= sizeb);
  return num;
}

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

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

  sort(T, T + q);

  cout << Binary(S, n, T, q) << endl;
}

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

int Binary(int a[], int sizea, int b[], int sizeb) {
  int num = 0;
  int j = 0;
  int i = 0;
  do {
    if (i >= sizea || j >= sizeb) {
      break;
    }

    if (a[i] == b[j]) {
      num++;
      i++;
      j++;
    } else if (a[i] > b[j]) {
      j++;
      if (j >= sizeb) {
        break;
      }
    } else if (a[i] < b[j]) {
      i++;
      if (i >= sizea) {
        break;
      }
    }
  } while (i <= sizea || j <= sizeb);
  return num;
}

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

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

  sort(T, T + q);

  cout << Binary(S, n, T, q) << endl;
}


#include <cstdio>
#include <iostream>
using namespace std;
int a[1000000], n;
int binarysearch(int key) {
  int start = 0;
  int end = n;
  while (start <= end) {
    int mid = (start + end) / 2;
    if (a[mid] == key)
      return 1;
    if (a[mid] < key)
      start = mid + 1;
    else if (key < a[mid])
      end = mid;
  }
}
int main() {
  int i, 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);
  return 0;
}

#include <cstdio>
#include <iostream>
using namespace std;
int a[1000000], n;
int binarysearch(int key) {
  int left = 0;
  int right = n;
  while (left < right) {
    int mid = (left + right) / 2;
    if (a[mid] == key)
      return 1;
    if (a[mid] < key)
      left = mid + 1;
    else if (key < a[mid])
      right = mid;
  }
  return 0;
}
int main() {
  int i, 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);
  return 0;
}


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

int main(void) {
  int n, q;
  std::vector<int> S(n);
  int T;
  int cnt = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%d", &S[i]);

  std::cin >> q;
  while (q--) {
    std::cin >> T;
    ;
    if (std::binary_search(S.begin(), S.end(), T))
      cnt++;
  }
  std::cout << cnt << std::endl;
}

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  vector<int> vc(n);
  for (int i = 0; i < n; i++)
    scanf("%d", &vc[i]);
  int ans = 0, q, a;
  scanf("%d", &q);
  sort(vc.begin(), vc.end());
  while (q--) {
    cin >> a;
    if (binary_search(vc.begin(), vc.end(), a))
      ans++;
  }
  printf("%d\\n", ans);
}


/*16D8103008D Yukki Nishimura 5/14 */

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

using namespace std;

#define MAX 100000

bool check(int C[], int y, int j) {
  if (j != 0) {
    for (int i = 0; i < j; i++) {
      if (C[i] == y) {
        return true;
      }
    }
  }

  return false; // 探索失敗
}

int func(int S[], int T[], int q, int n) {
  int s = n;
  int t = q;
  int j = 0;

  int C[MAX] = {};

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

    for (int k = 0; k < t; k++) {
      if (check(C, S[i], j)) {
        break;
      }

      else if (S[i] == T[k]) {
        C[j] = S[i];
        j++;
        break;
      }
    }
  }

  return j;
}

int main(void) {
  int n, q, c;

  int S[MAX] = {}, T[MAX] = {};

  cin >> n;

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

  cin >> q;

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

  c = func(S, T, q, n);

  cout << c << endl;

  return 0;
}

#include <stdio.h>

int main(void) {
  int n, q, si, ti, l, r, m, c = 0;
  int S[100005];
  int T[50005];

  scanf("%d", &n);
  for (si = 0; si < n; si++) {
    scanf("%d", &S[si]);
  }
  scanf("%d", &q);
  for (ti = 0; ti < q; ti++) {
    scanf("%d", &T[ti]);
  }
  for (ti = 0; ti < q; ti++) {
    l = 0;
    r = n;
    while (l < r) {
      m = (l + r) / 2;
      if (S[m] > T[ti]) {
        r = m;
      } else if (S[m] < T[ti]) {
        l = m + 1;
      } else {
        c++;
        break;
      }
    }
  }

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

  return 0;
}


#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF = 100000000;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
using namespace std;
typedef pair<int, int> P;
typedef long long ll;

bool binary_search(int *a, int n, int x) {
  int l = 0, r = n;
  while (r - l > 0) {
    int mid = (l + r) / 2;
    if (a[mid] < x)
      l = mid;
    else if (a[mid] == x)
      return true;
    else
      r = mid;
  }
  // cout<<l<<","<<r<<endl;
  return false;
}

int n;
int S[100005];
int q;
int main() {
  int ans = 0;
  cin >> n;
  rep(i, n) cin >> S[i];
  cin >> q;
  rep(i, q) {
    int t;
    cin >> t;
    if (binary_search(S, n, t))
      ans++;
  }
  cout << ans << endl;
  return 0;
}

#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF = 100000000;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
using namespace std;
typedef pair<int, int> P;
typedef long long ll;

bool binary_search(int *a, int n, int x) {
  int l = 0, r = n;
  while (r - l > 0) {
    int mid = (l + r) / 2;
    if (a[mid] < x)
      l = mid + 1;
    else if (a[mid] == x)
      return true;
    else
      r = mid;
  }
  // cout<<l<<","<<r<<endl;
  return false;
}

int n;
int S[100005];
int q;
int main() {
  int ans = 0;
  cin >> n;
  rep(i, n) cin >> S[i];
  cin >> q;
  rep(i, q) {
    int t;
    cin >> t;
    if (binary_search(S, n, t))
      ans++;
  }
  cout << ans << endl;
  return 0;
}


//
//  main.cpp
//  binary_search
//
//  Created by ???????????? on 2017/10/06.
//  Copyright ?? 2017 ????????????. All rights reserved.
//

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

using namespace std;

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

int main(int argc, const char *argv[]) {
  int n, i, ct, q, key;

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

  ct = 0;
  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    scanf("%d", &key);
    bool found = binary_search(S, n, key);
    if (found)
      ct++;
  }
  cout << ct << endl;
  ;
  return 0;
}

//
//  main.cpp
//  binary_search
//
//  Created by ???????????? on 2017/10/06.
//  Copyright ?? 2017 ????????????. All rights reserved.
//

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

using namespace std;

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

int main(int argc, const char *argv[]) {
  int n, i, ct, q, key;

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

  ct = 0;
  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    scanf("%d", &key);
    bool found = binary_search(S, n, key);
    if (found)
      ct++;
  }
  cout << ct << endl;
  ;
  return 0;
}


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

bool bs(int val, vector<int> &v) {
  int l = 0, r = v.size() - 1;
  while (l < r) {
    int mid = (l + r) >> 1;
    if (v[mid] == val)
      return true;
    else if (v[mid] > val)
      r = mid;
    else
      l = mid + 1;
  }
  return false;
}

int main() {
  int n, m;
  scanf("%d", &n);
  int v;
  vector<int> s, t;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &v);
    s.push_back(v);
  }
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    scanf("%d", &v);
    t.push_back(v);
  }
  for (int x : t) {
    if (bs(x, s)) {
      ans++;
    }
  }
  printf("%d\\n", ans);
  return 0;
}

#include "bits/stdc++.h"
#include <unordered_map>
#include <unordered_set>
#pragma warning(disable : 4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

int main() {
  int N;
  cin >> N;
  vector<int> ns(N);
  for (int i = 0; i < N; ++i) {
    cin >> ns[i];
  }
  int Q;
  cin >> Q;
  int sum = 0;
  while (Q--) {
    int a;
    cin >> a;
    auto it = lower_bound(ns.begin(), ns.end(), a);
    auto jt = upper_bound(ns.begin(), ns.end(), a);
    sum += min(1, int(jt - it));
  }
  cout << sum << endl;
  return 0;
}


#include <stdio.h>
int Binarysearch(int *, int, int);
#define N 10000

int main() {
  int i, s, array[N], t, m, sum = 0;

  scanf("%d", &s);
  for (i = 0; i < s; i++) {
    scanf("%d", &array[i]);
  }
  scanf("%d", &t);
  for (i = 0; i < t; i++) {
    scanf("%d", &m);
    if (Binarysearch(array, s, m))
      sum++;
  }
  printf("%d\\n", sum);
  return 0;
}

int Binarysearch(int A[], int x, int key) {
  int left = 0, right, mid = 0;
  right = x;
  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;
}

#include <stdio.h>
int Binarysearch(int *, int, int);
#define N 100005

int main() {
  int i, s, array[N], t, m, sum = 0;

  scanf("%d", &s);
  for (i = 0; i < s; i++) {
    scanf("%d", &array[i]);
  }
  scanf("%d", &t);
  for (i = 0; i < t; i++) {
    scanf("%d", &m);
    if (Binarysearch(array, s, m))
      sum++;
  }
  printf("%d\\n", sum);
  return 0;
}

int Binarysearch(int A[], int x, int key) {
  int left = 0, right, mid = 0;
  right = x;
  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;
}


#include <cmath>
#include <iostream>

using namespace std;

int main() {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  cout << sqrt(pow(double(x1 - x2), 2.0) + pow(double(y1 - y2), 2.0)) << endl;
  return 1;
}

#include <cmath>
#include <iomanip>
#include <iostream>

using namespace std;

int main() {
  double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  cout << fixed << setprecision(7);
  cout << sqrt(pow((x1 - x2), 2) + pow((y1 - y2), 2)) << endl;
  return 0;
}


#include <iomanip>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
  double x, y, x1, x2, y1, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  x = x2 - x1;
  y = y2 - y1;
  if (x == 0) {
    cout << fixed << setprecision(5) << fabs(y) << "\\n";
    return 0;
  } else if (y == 0) {
    cout << fixed << setprecision(5) << fabs(x) << "\\n";
    return 0;
  }

  double v = x * x + y * y, d = 1, eps = 0.00001;
  do {
    d = (d + v / d) / 2.0L;
  } while (fabs(v - d * d) > eps);

  cout << fixed << setprecision(5) << d << "\\n";

  return 0;
}

#include <iomanip>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
  double x, y, x1, x2, y1, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  x = fabs(x2 - x1);
  y = fabs(y2 - y1);
  if (x == 0) {
    cout << fixed << setprecision(5) << y << "\\n";
    return 0;
  } else if (y == 0) {
    cout << fixed << setprecision(5) << x << "\\n";
    return 0;
  }

  int c = 0;

  double v = x * x + y * y, d = max(x, y), eps = 0.00001;
  do {
    d = (d + v / d) / 2.0L;
    ++c;
  } while (c < 5);

  cout << fixed << setprecision(5) << d << "\\n";

  return 0;
}


#include <stdio.h>

#ifndef DEBUG
#define fprintf (void)
#endif

double absval(double x);

int main(void) {

  double x1, y1, x2, y2;
  double b = 0;
  int n;
  scanf("%lf", &x1);
  scanf("%lf", &y1);
  scanf("%lf", &x2);
  scanf("%lf", &y2);
  double dx = absval(x1 - x2);
  double dy = absval(y1 - y2);

  double x = dx * dx + dy * dy;
  fprintf(stdout, "%lf\\n", x);

  scanf("%d", &n);

  while (b * b < x) {
    b++;
  }
  while (absval(b * b - x) > 0.000001) {
    b = (b * b + x) / (2 * b);
    fprintf(stdout, "%f\\n", b);
  }
  printf("%f\\n", b);

  return 0;
}

double absval(double x) {
  if (x < 0) {
    return -x;
  } else {
    return x;
  }
}

#include <stdio.h>

#ifndef DEBUG
#define fprintf (void)
#endif

double absval(double x);

int main(void) {

  double x1, y1, x2, y2;
  double b = 0;
  int n;
  scanf("%lf", &x1);
  scanf("%lf", &y1);
  scanf("%lf", &x2);
  scanf("%lf", &y2);
  double dx = absval(x1 - x2);
  double dy = absval(y1 - y2);

  double x = dx * dx + dy * dy;
  fprintf(stdout, "%lf\\n", x);

  scanf("%d", &n);

  while (b * b < x) {
    b++;
  }
  while (absval(b * b - x) > 0.0001) {
    b = (b * b + x) / (2 * b);
    fprintf(stdout, "%f\\n", b);
  }
  printf("%f\\n", b);

  return 0;
}

double absval(double x) {
  if (x < 0) {
    return -x;
  } else {
    return x;
  }
}


#include <cmath>
#include <cstdio>

int main() {
  double x1, x2, y1, y2;
  scanf("%lf %lf %lf %lf", x1, y1, x2, y2);
  double d = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  printf("%lf\\n", d);
  return 0;
}

#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  double x1, x2, y1, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  double d = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  printf("%lf\\n", d);
  return 0;
}


#include <iomanip>
#include <iostream>

using namespace std;

double sqrt(double x) {
  double dx, ans = x;
  for (;;) {
    dx = (ans - x / ans) / 2;
    ans -= dx;
    if (dx < 0.00001)
      break;
  }
  return ans;
}

int main() {
  double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  x1 -= x2;
  y1 -= y2;
  cout << fixed << setprecision(5) << sqrt(x1 * x1 + y1 * y1) << endl;
  return 0;
}

#include <cmath>
#include <iomanip>
#include <iostream>

using namespace std;

int main() {
  double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  x1 -= x2;
  y1 -= y2;
  cout << fixed << setprecision(5) << sqrt(x1 * x1 + y1 * y1) << endl;
  return 0;
}


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

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

int main() {
  long double x1, x2, y1, y2, d;
  scanf("%lf %lf %lf %lf", x1, y1, x2, y2);
  d = powl(powl(x1 - x2, 2.0) + powl(y1 - y2, 2.0), 0.5);
  printf("%.10lf\\n", d);
  return 0;
}

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

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

int main() {
  long double x1, x2, y1, y2, d;
  cin >> x1 >> y1 >> x2 >> y2;
  d = powl(powl(x1 - x2, 2.0) + powl(y1 - y2, 2.0), 0.5);
  cout << fixed << d << "\\n";
  return 0;
}


#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

using namespace std;

void Solution() {
  while (1) {
    int n;
    int s[100] = {0};
    double m;
    long int sum = 0;
    double aa = 0;

    cin >> n;

    if (n == 0)
      break;

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

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

    m = (double)sum / n; // type change !

    for (int i = 0; i < n; i++) {
      aa += (s[i] - m) * (s[i] - m);
    }

    cout << fixed << setprecision(8) << sqrt(aa / n) << endl;
  }
}

int main() {
  Solution();
  return 0;
}

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

using namespace std;

void Solution() {
  while (1) {
    int n;
    long int s[1000] = {0};
    double m;
    long int sum = 0;
    double aa = 0;

    cin >> n;

    if (n == 0)
      break;

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

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

    m = (double)sum / n; // type change !

    for (int i = 0; i < n; i++) {
      aa += (s[i] - m) * (s[i] - m);
    }

    cout << fixed << setprecision(4) << sqrt(aa / n) << endl;
  }
}

int main() {
  Solution();
  return 0;
}


#include <algorithm>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>

#include <ctype.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

int main() {

  while (1) {
    int num = 0, i = 0;
    double ave = 0, sum = 0, ans = 0;
    double s[101] = {0};

    cin >> num;
    if (num == 0)
      break;
    for (i = 0; i < num; i++) {
      cin >> s[i];
      ave += s[i];
    }
    ave = ave / num;
    //
    for (i = 0; i < num; i++) {
      sum += ((s[i] - ave) * (s[i] - ave));
    }
    sum = sum / num;
    ans = sqrt(sum);
    cout << fixed << setprecision(8) << ans << endl;
  }

  return 0;
}

#include <algorithm>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>

#include <ctype.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

int main() {

  while (1) {
    int num = 0, i = 0;
    double ave = 0, sum = 0, ans = 0;
    double s[1000] = {0};

    cin >> num;
    if (num == 0)
      break;
    for (i = 0; i < num; i++) {
      cin >> s[i];
      ave += s[i];
    }
    ave = ave / num;
    for (i = 0; i < num; i++) {
      sum += ((s[i] - ave) * (s[i] - ave));
    }
    sum = sum / num;
    ans = sqrt(sum);
    cout << fixed << ans << endl;
  }

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  while (n) {
    int s[n];
    double sum = 0;
    for (int i = 0; i < n; i++) {
      cin >> s[i];
      sum += s[i];
    }
    double ave = sum / n;
    sum = 0.0;
    for (int i = 0; i < n; i++)
      sum += (s[i] - ave) * (s[i] - ave);
    cout << sqrt(sum / n) << endl;
  }
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  while (n) {
    int s[n];
    double sum = 0;
    for (int i = 0; i < n; i++) {
      cin >> s[i];
      sum += s[i];
    }
    double ave = sum / n;
    sum = 0.0;
    for (int i = 0; i < n; i++)
      sum += (s[i] - ave) * (s[i] - ave);
    cout << sqrt(sum / n) << endl;
    cin >> n;
  }
  return 0;
}


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

int main() {
  int n;
  double s[105];
  while (cin >> n && n != 0) {
    double sum = 0;
    for (int i = 0; i < n; i++) {
      cin >> s[i];
      sum += s[i];
    }
    double avg = sum / n;
    sum = 0;
    for (int i = 0; i < n; i++) {
      sum += (s[i] - avg) * (s[i] - avg);
    }
    if (sum == 0) {
      printf("%lf\\n", sum);
    } else {
      printf("%lf\\n", sqrt(sum / n));
    }
  }
  return 0;
}

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

int main() {
  int n;
  double s[1005];
  while (cin >> n && n != 0) {
    double sum = 0;
    for (int i = 0; i < n; i++) {
      cin >> s[i];
      sum += s[i];
    }
    double avg = sum / n;
    sum = 0;
    for (int i = 0; i < n; i++) {
      sum += (s[i] - avg) * (s[i] - avg);
    }
    if (sum == 0) {
      printf("%lf\\n", sum);
    } else {
      printf("%lf\\n", sqrt(sum / n));
    }
  }
  return 0;
}


#include <iostream>
#include <math.h>

#define REP(i, a, b) for (i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)

using namespace std;

int main() {
  int n, s[100], i;
  double m, d;

  cout.precision(8);
  while (1) {
    cin >> n;
    if (n == 0)
      break;
    m = 0;
    d = 0;
    rep(i, n) {
      cin >> s[i];
      m += s[i];
    }
    m = m / n;
    rep(i, n) d += pow(s[i] - m, 2.0);
    d = sqrt(d / n);
    cout << fixed << d << endl;
  }
  return 0;
}

#include <iostream>
#include <math.h>

#define REP(i, a, b) for (i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)

using namespace std;

int main() {
  int n, s[1000], i;
  double m, d;

  cout.precision(8);
  while (1) {
    cin >> n;
    if (n == 0)
      break;
    m = 0;
    d = 0;
    rep(i, n) {
      cin >> s[i];
      m += s[i];
    }
    m = m / n;
    rep(i, n) d += pow(s[i] - m, 2.0);
    d = sqrt(d / n);
    cout << fixed << d << endl;
  }
  return 0;
}


#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;

int main() {
  int n;
  int S[100];
  double sum = 0;
  double std = 0;
  double deviate = 0;
  while (1) {
    cin >> n;
    if (n == 0)
      break;
    for (int i = 0; i < n; i++)
      cin >> S[i];
    for (int i = 0; i < n; i++) {
      sum += S[i];
    }
    for (int i = 0; i < n; i++) {
      deviate += (S[i] - sum / n) * (S[i] - sum / n);
    }

    printf("%lf\\n", sqrt(deviate / n));
    sum = 0;
    std = 0;
    deviate = 0;
  }

  return 0;
}

#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;

int main() {
  int n;
  int S[1000];
  double sum = 0;
  double std = 0;
  double deviate = 0;
  while (1) {
    cin >> n;
    if (n == 0)
      break;
    for (int i = 0; i < n; i++)
      cin >> S[i];
    for (int i = 0; i < n; i++) {
      sum += S[i];
    }
    for (int i = 0; i < n; i++) {
      deviate += (S[i] - sum / n) * (S[i] - sum / n);
    }

    printf("%lf\\n", sqrt(deviate / n));
    sum = 0;
    std = 0;
    deviate = 0;
  }

  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 (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265358979

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

int main(void) {
  int n;
  while (cin >> n, n) {
    int s[101];
    double alpha = 0, ave = 0;
    FOR(i, 1, n) {
      cin >> s[i];
      ave += s[i];
    }
    ave /= n;
    FOR(i, 1, n) { alpha += (s[i] - ave) * (s[i] - ave); }
    alpha /= n;
    alpha = sqrt(alpha);
    printf("%.10lf\\n", alpha);
  }
  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 (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265358979

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

int main(void) {
  int n;
  while (cin >> n, n) {
    int s[1001];
    double alpha = 0, ave = 0;
    FOR(i, 1, n) {
      cin >> s[i];
      ave += s[i];
    }
    ave /= n;
    FOR(i, 1, n) { alpha += (s[i] - ave) * (s[i] - ave); }
    alpha /= n;
    alpha = sqrt(alpha);
    printf("%.10lf\\n", alpha);
  }
  return 0;
}


#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <sstream>
using namespace std;
#define MPI 3.14159265358979323846

int main() {
  while (true) {
    int n, s[101], sum = 0;
    double a = 0, m;
    cin >> n;
    if (n == 0)
      break;
    for (int i = 0; i < n; i++) {
      cin >> s[i];
      sum += s[i];
    }
    m = (double)sum / (double)n;
    for (int i = 0; i < n; i++) {
      a += pow(s[i] - m, 2) / (double)n;
    }
    printf("%.8f\\n", sqrt(a));
  }
  return 0;
}

#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <sstream>
using namespace std;
#define MPI 3.14159265358979323846

int main() {
  while (true) {
    int n, s[1001], sum = 0;
    double a = 0, m;
    cin >> n;
    if (n == 0)
      break;
    for (int i = 0; i < n; i++) {
      cin >> s[i];
      sum += s[i];
    }
    m = (double)sum / (double)n;
    for (int i = 0; i < n; i++) {
      a += pow(s[i] - m, 2) / (double)n;
    }
    printf("%.8f\\n", sqrt(a));
  }
  return 0;
}


#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
using namespace std;
int main(void) {
  // Your code here!
  long double a, b, c = 0, d, e, f, g = 0;
  int A[500];
  while (1) {

    cin >> b;
    if (b == 0) {
      break;
    }
    for (int i = 0; i < b; i++) {
      cin >> A[i];
      c += A[i];
    }
    c = c / b;
    for (int i = 0; i < b; i++) {
      g += pow((A[i] - c), 2) / b;
    }
    g = sqrt(g);
    // cout<<printf("%.10lf\\n", sqrt(e))<<endl;
    // e=sqrt(e);
    //  cout << f << endl;
    std::cout << setprecision(16) << g << endl;
    c = 0;
    g = 0;
    A[500] = 0;
  }
  return 0;
}

#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
using namespace std;
int main(void) {
  // Your code here!
  long double a, b, c = 0, d, e, f, g = 0;
  int A[1000];
  while (1) {

    cin >> b;
    if (b == 0) {
      break;
    }
    for (int i = 0; i < b; i++) {
      cin >> A[i];
      c += A[i];
    }
    c = c / b;
    for (int i = 0; i < b; i++) {
      g += pow((A[i] - c), 2) / b;
    }
    g = sqrt(g);
    // cout<<printf("%.10lf\\n", sqrt(e))<<endl;
    // e=sqrt(e);
    //  cout << f << endl;
    std::cout << setprecision(16) << g << endl;
    c = 0;
    g = 0;
    A[1000] = 0;
  }
  return 0;
}


#include <cmath>
#include <iomanip>
#include <iostream>
using namespace std;
int main(void) {
  int n, s[101], i;
  double m, a2, a;
  cin >> n;

  while (n != 0) {
    m = 0;
    a2 = 0;
    for (i = 0; i < n; i++) {
      cin >> s[i];
      m += s[i];
    }
    m = m / n;
    for (i = 0; i < n; i++) {
      a2 += (s[i] - m) * (s[i] - m);
    }
    a2 = a2 / n;
    a = sqrt(a2);

    cout << fixed << setprecision(5) << a << endl;

    cin >> n;
  }
  return 0;
}

#include <cmath>
#include <iomanip>
#include <iostream>
using namespace std;
int main(void) {
  long int n, s[1001], i;
  double m, a2, a;
  cin >> n;

  while (n != 0) {
    m = 0;
    a2 = 0;
    for (i = 0; i < n; i++) {
      cin >> s[i];
      m += s[i];
    }
    m = m / n;
    for (i = 0; i < n; i++) {
      a2 += (s[i] - m) * (s[i] - m);
    }
    a2 = a2 / n;
    a = sqrt(a2);

    cout << fixed << setprecision(5) << a << endl;

    cin >> n;
  }
  return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <queue>
#include <string>
#include <utility>
#include <vector>
#define INF 2147483647

using namespace std;

int main() {
  double s[105], ave, a;
  int n;

  while (1) {
    cin >> n;
    if (n == 0)
      break;
    ave = 0;
    for (int i = 0; i < n; i++) {
      cin >> s[i];
      ave += s[i];
    }
    ave /= n;
    a = 0;
    for (int i = 0; i < n; i++) {
      a += pow((s[i] - ave), 2);
    }
    a /= n;
    cout << fixed << setprecision(8) << sqrt(a) << endl;
  }

  return (0);
}

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <queue>
#include <string>
#include <utility>
#include <vector>
#define INF 2147483647

using namespace std;

int main() {
  double s[1005], ave, a;
  int n;

  while (1) {
    cin >> n;
    if (n == 0)
      break;
    ave = 0;
    for (int i = 0; i < n; i++) {
      cin >> s[i];
      ave += s[i];
    }
    ave /= n;
    a = 0;
    for (int i = 0; i < n; i++) {
      a += pow((s[i] - ave), 2);
    }
    a /= n;
    cout << fixed << setprecision(8) << sqrt(a) << endl;
  }

  return (0);
}


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

int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0)
      break;
    double s[100], a = 0, m = 0;
    for (int i = 0; i < n; i++) {
      cin >> s[i];
      m += s[i];
    }
    m /= n;
    for (int i = 0; i < n; i++)
      a += pow(s[i] - m, 2);
    a /= n;
    a = pow(a, 0.5);
    cout << fixed << setprecision(10) << a << endl;
  }
}

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

int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0)
      break;
    double s[1000], a = 0, m = 0;
    for (int i = 0; i < n; i++) {
      cin >> s[i];
      m += s[i];
    }
    m /= n;
    for (int i = 0; i < n; i++)
      a += pow(s[i] - m, 2);
    a /= n;
    a = pow(a, 0.5);
    cout << fixed << setprecision(10) << a << endl;
  }
}