import java.util.Scanner;

class Main{

  static boolean binarySearch(int[] a, int x){
    int left = 0;
    int right = a.length;

    while(left < right){
      int k = (left + right) / 2;
      int w = a[k];
      if(w == x)
        return true;
      else if(x > w)
        left = k + 1;
      else
        right = k;
    }

    return false;
  }

  public static void main(String[] arsg){
    Scanner stdIn = new Scanner(System.in);
    int n = stdIn.nextInt();
    int[] a = new int[n];

    for(int i = 0; i < n; i++)
      a[i] = stdIn.nextInt();

    int q = stdIn.nextInt();
    int count = 0;
    for(int i = 0; i < q; i++){
      int x = stdIn.nextInt();
      if(binarySearch(a, x))
        count++;
    }


    System.out.println(count);
  }
} import java.util.Scanner; Scanner java.util class Main{

  static boolean binarySearch(int[] a, int x){
    int left = 0;
    int right = a.length;

    while(left < right){
      int k = (left + right) / 2;
      int w = a[k];
      if(w == x)
        return true;
      else if(x > w)
        left = k + 1;
      else
        right = k;
    }

    return false;
  }

  public static void main(String[] arsg){
    Scanner stdIn = new Scanner(System.in);
    int n = stdIn.nextInt();
    int[] a = new int[n];

    for(int i = 0; i < n; i++)
      a[i] = stdIn.nextInt();

    int q = stdIn.nextInt();
    int count = 0;
    for(int i = 0; i < q; i++){
      int x = stdIn.nextInt();
      if(binarySearch(a, x))
        count++;
    }


    System.out.println(count);
  }
} Main static boolean binarySearch(int[] a, int x){
    int left = 0;
    int right = a.length;

    while(left < right){
      int k = (left + right) / 2;
      int w = a[k];
      if(w == x)
        return true;
      else if(x > w)
        left = k + 1;
      else
        right = k;
    }

    return false;
  } binarySearch {
    int left = 0;
    int right = a.length;

    while(left < right){
      int k = (left + right) / 2;
      int w = a[k];
      if(w == x)
        return true;
      else if(x > w)
        left = k + 1;
      else
        right = k;
    }

    return false;
  } int left = 0; left 0 int right = a.length; right a.length a a.length while(left < right){
      int k = (left + right) / 2;
      int w = a[k];
      if(w == x)
        return true;
      else if(x > w)
        left = k + 1;
      else
        right = k;
    } left < right left right {
      int k = (left + right) / 2;
      int w = a[k];
      if(w == x)
        return true;
      else if(x > w)
        left = k + 1;
      else
        right = k;
    } int k = (left + right) / 2; k (left + right) / 2 (left + right) left right 2 int w = a[k]; w a[k] a k if(w == x)
        return true;
      else if(x > w)
        left = k + 1;
      else
        right = k; w == x w x return true; true if(x > w)
        left = k + 1;
      else
        right = k; x > w x w left = k + 1 left k + 1 k 1 right = k right k return false; false int[] a a int x x public static void main(String[] arsg){
    Scanner stdIn = new Scanner(System.in);
    int n = stdIn.nextInt();
    int[] a = new int[n];

    for(int i = 0; i < n; i++)
      a[i] = stdIn.nextInt();

    int q = stdIn.nextInt();
    int count = 0;
    for(int i = 0; i < q; i++){
      int x = stdIn.nextInt();
      if(binarySearch(a, x))
        count++;
    }


    System.out.println(count);
  } main {
    Scanner stdIn = new Scanner(System.in);
    int n = stdIn.nextInt();
    int[] a = new int[n];

    for(int i = 0; i < n; i++)
      a[i] = stdIn.nextInt();

    int q = stdIn.nextInt();
    int count = 0;
    for(int i = 0; i < q; i++){
      int x = stdIn.nextInt();
      if(binarySearch(a, x))
        count++;
    }


    System.out.println(count);
  } Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) int n = stdIn.nextInt(); n stdIn.nextInt() stdIn.nextInt stdIn int[] a = new int[n]; a new int[n] n for(int i = 0; i < n; i++)
      a[i] = stdIn.nextInt(); int i = 0; int i = 0; i 0 i < n i n i++ i++ i a[i] = stdIn.nextInt(); a[i] = stdIn.nextInt() a[i] a i stdIn.nextInt() stdIn.nextInt stdIn int q = stdIn.nextInt(); q stdIn.nextInt() stdIn.nextInt stdIn int count = 0; count 0 for(int i = 0; i < q; i++){
      int x = stdIn.nextInt();
      if(binarySearch(a, x))
        count++;
    } int i = 0; int i = 0; i 0 i < q i q i++ i++ i {
      int x = stdIn.nextInt();
      if(binarySearch(a, x))
        count++;
    } {
      int x = stdIn.nextInt();
      if(binarySearch(a, x))
        count++;
    } int x = stdIn.nextInt(); x stdIn.nextInt() stdIn.nextInt stdIn if(binarySearch(a, x))
        count++; binarySearch(a, x) binarySearch a x count++ count System.out.println(count) System.out.println System.out System System.out count String[] arsg arsg
import java.util.Scanner;

class Main{

  static boolean binarySearch(int[] a, int x){
    int left = 0;
    int right = a.length;

    while(left < right){
      int k = (left + right) / 2;
      int w = a[k];
      if(w == x)
        return true;
      else if(x > w)
        left = k + 1;
      else
        right = k;
    }

    return false;
  }

  public static void main(String[] arsg){
    Scanner stdIn = new Scanner(System.in);
    int n = stdIn.nextInt();
    int[] a = new int[n];

    for(int i = 0; i < n; i++)
      a[i] = stdIn.nextInt();

    int q = stdIn.nextInt();
    int count = 0;
    for(int i = 0; i < q; i++){
      int x = stdIn.nextInt();
      if(binarySearch(a, x))
        count++;
    }


    System.out.println(count);
  }
}