import java.util.Scanner;

public class Main {

    static Scanner scan;
    static int count = 0;

    public static void main(String[] args) {
        scan = new Scanner(System.in);

         // get input
         final int slen = scan.nextInt();
         int[] s = new int[slen];
         for(int i = 0; i < slen; i++) {
             s[i] = scan.nextInt();
         }

         final int tlen = scan.nextInt();
         int[] t = new int[tlen];
         for(int i = 0; i < tlen; i++){
             t[i] = scan.nextInt();
         }

         // carry out binary search
         for(int i = 0; i < tlen; i++) {
             binarySearch(s, t[i]);
         }

         System.out.println(count);
    }

    public static void binarySearch(int[] s, int t){
        int hi = 0; int ti = s.length-1; //先頭のインデックス; 末尾のインデックス;
        int p;

        while(hi <= ti) {
            p = (hi + ti) / 2; //探索対象インデックス
            if(s[p] == t) {
                count++;
                break;
            } else if(s[p] < t) {
                hi = p + 1;
                continue;
            } else {
                ti = p - 1;
                continue;
            }
        }

        return;
    }
}
 import java.util.Scanner; Scanner java.util public class Main {

    static Scanner scan;
    static int count = 0;

    public static void main(String[] args) {
        scan = new Scanner(System.in);

         // get input
         final int slen = scan.nextInt();
         int[] s = new int[slen];
         for(int i = 0; i < slen; i++) {
             s[i] = scan.nextInt();
         }

         final int tlen = scan.nextInt();
         int[] t = new int[tlen];
         for(int i = 0; i < tlen; i++){
             t[i] = scan.nextInt();
         }

         // carry out binary search
         for(int i = 0; i < tlen; i++) {
             binarySearch(s, t[i]);
         }

         System.out.println(count);
    }

    public static void binarySearch(int[] s, int t){
        int hi = 0; int ti = s.length-1; //先頭のインデックス; 末尾のインデックス;
        int p;

        while(hi <= ti) {
            p = (hi + ti) / 2; //探索対象インデックス
            if(s[p] == t) {
                count++;
                break;
            } else if(s[p] < t) {
                hi = p + 1;
                continue;
            } else {
                ti = p - 1;
                continue;
            }
        }

        return;
    }
} Main static Scanner scan; scan static int count = 0; count 0 public static void main(String[] args) {
        scan = new Scanner(System.in);

         // get input
         final int slen = scan.nextInt();
         int[] s = new int[slen];
         for(int i = 0; i < slen; i++) {
             s[i] = scan.nextInt();
         }

         final int tlen = scan.nextInt();
         int[] t = new int[tlen];
         for(int i = 0; i < tlen; i++){
             t[i] = scan.nextInt();
         }

         // carry out binary search
         for(int i = 0; i < tlen; i++) {
             binarySearch(s, t[i]);
         }

         System.out.println(count);
    } main {
        scan = new Scanner(System.in);

         // get input
         final int slen = scan.nextInt();
         int[] s = new int[slen];
         for(int i = 0; i < slen; i++) {
             s[i] = scan.nextInt();
         }

         final int tlen = scan.nextInt();
         int[] t = new int[tlen];
         for(int i = 0; i < tlen; i++){
             t[i] = scan.nextInt();
         }

         // carry out binary search
         for(int i = 0; i < tlen; i++) {
             binarySearch(s, t[i]);
         }

         System.out.println(count);
    } scan = new Scanner(System.in) scan new Scanner(System.in) final int slen = scan.nextInt(); slen scan.nextInt() scan.nextInt scan int[] s = new int[slen]; s new int[slen] slen for(int i = 0; i < slen; i++) {
             s[i] = scan.nextInt();
         } int i = 0; int i = 0; i 0 i < slen i slen i++ i++ i {
             s[i] = scan.nextInt();
         } {
             s[i] = scan.nextInt();
         } s[i] = scan.nextInt() s[i] s i scan.nextInt() scan.nextInt scan final int tlen = scan.nextInt(); tlen scan.nextInt() scan.nextInt scan int[] t = new int[tlen]; t new int[tlen] tlen for(int i = 0; i < tlen; i++){
             t[i] = scan.nextInt();
         } int i = 0; int i = 0; i 0 i < tlen i tlen i++ i++ i {
             t[i] = scan.nextInt();
         } {
             t[i] = scan.nextInt();
         } t[i] = scan.nextInt() t[i] t i scan.nextInt() scan.nextInt scan for(int i = 0; i < tlen; i++) {
             binarySearch(s, t[i]);
         } int i = 0; int i = 0; i 0 i < tlen i tlen i++ i++ i {
             binarySearch(s, t[i]);
         } {
             binarySearch(s, t[i]);
         } binarySearch(s, t[i]) binarySearch s t[i] t i System.out.println(count) System.out.println System.out System System.out count String[] args args public static void binarySearch(int[] s, int t){
        int hi = 0; int ti = s.length-1; //先頭のインデックス; 末尾のインデックス;
        int p;

        while(hi <= ti) {
            p = (hi + ti) / 2; //探索対象インデックス
            if(s[p] == t) {
                count++;
                break;
            } else if(s[p] < t) {
                hi = p + 1;
                continue;
            } else {
                ti = p - 1;
                continue;
            }
        }

        return;
    } binarySearch {
        int hi = 0; int ti = s.length-1; //先頭のインデックス; 末尾のインデックス;
        int p;

        while(hi <= ti) {
            p = (hi + ti) / 2; //探索対象インデックス
            if(s[p] == t) {
                count++;
                break;
            } else if(s[p] < t) {
                hi = p + 1;
                continue;
            } else {
                ti = p - 1;
                continue;
            }
        }

        return;
    } int hi = 0; hi 0 int ti = s.length-1; ti s.length-1 s.length s s.length 1 int p; p while(hi <= ti) {
            p = (hi + ti) / 2; //探索対象インデックス
            if(s[p] == t) {
                count++;
                break;
            } else if(s[p] < t) {
                hi = p + 1;
                continue;
            } else {
                ti = p - 1;
                continue;
            }
        } hi <= ti hi ti {
            p = (hi + ti) / 2; //探索対象インデックス
            if(s[p] == t) {
                count++;
                break;
            } else if(s[p] < t) {
                hi = p + 1;
                continue;
            } else {
                ti = p - 1;
                continue;
            }
        } p = (hi + ti) / 2 p (hi + ti) / 2 (hi + ti) hi ti 2 if(s[p] == t) {
                count++;
                break;
            } else if(s[p] < t) {
                hi = p + 1;
                continue;
            } else {
                ti = p - 1;
                continue;
            } s[p] == t s[p] s p t {
                count++;
                break;
            } count++ count break; if(s[p] < t) {
                hi = p + 1;
                continue;
            } else {
                ti = p - 1;
                continue;
            } s[p] < t s[p] s p t {
                hi = p + 1;
                continue;
            } hi = p + 1 hi p + 1 p 1 continue; {
                ti = p - 1;
                continue;
            } ti = p - 1 ti p - 1 p 1 continue; return; int[] s s int t t public class Main {

    static Scanner scan;
    static int count = 0;

    public static void main(String[] args) {
        scan = new Scanner(System.in);

         // get input
         final int slen = scan.nextInt();
         int[] s = new int[slen];
         for(int i = 0; i < slen; i++) {
             s[i] = scan.nextInt();
         }

         final int tlen = scan.nextInt();
         int[] t = new int[tlen];
         for(int i = 0; i < tlen; i++){
             t[i] = scan.nextInt();
         }

         // carry out binary search
         for(int i = 0; i < tlen; i++) {
             binarySearch(s, t[i]);
         }

         System.out.println(count);
    }

    public static void binarySearch(int[] s, int t){
        int hi = 0; int ti = s.length-1; //先頭のインデックス; 末尾のインデックス;
        int p;

        while(hi <= ti) {
            p = (hi + ti) / 2; //探索対象インデックス
            if(s[p] == t) {
                count++;
                break;
            } else if(s[p] < t) {
                hi = p + 1;
                continue;
            } else {
                ti = p - 1;
                continue;
            }
        }

        return;
    }
} public class Main {

    static Scanner scan;
    static int count = 0;

    public static void main(String[] args) {
        scan = new Scanner(System.in);

         // get input
         final int slen = scan.nextInt();
         int[] s = new int[slen];
         for(int i = 0; i < slen; i++) {
             s[i] = scan.nextInt();
         }

         final int tlen = scan.nextInt();
         int[] t = new int[tlen];
         for(int i = 0; i < tlen; i++){
             t[i] = scan.nextInt();
         }

         // carry out binary search
         for(int i = 0; i < tlen; i++) {
             binarySearch(s, t[i]);
         }

         System.out.println(count);
    }

    public static void binarySearch(int[] s, int t){
        int hi = 0; int ti = s.length-1; //先頭のインデックス; 末尾のインデックス;
        int p;

        while(hi <= ti) {
            p = (hi + ti) / 2; //探索対象インデックス
            if(s[p] == t) {
                count++;
                break;
            } else if(s[p] < t) {
                hi = p + 1;
                continue;
            } else {
                ti = p - 1;
                continue;
            }
        }

        return;
    }
} Main
import java.util.Scanner;

public class Main {

    static Scanner scan;
    static int count = 0;

    public static void main(String[] args) {
        scan = new Scanner(System.in);

         // get input
         final int slen = scan.nextInt();
         int[] s = new int[slen];
         for(int i = 0; i < slen; i++) {
             s[i] = scan.nextInt();
         }

         final int tlen = scan.nextInt();
         int[] t = new int[tlen];
         for(int i = 0; i < tlen; i++){
             t[i] = scan.nextInt();
         }

         // carry out binary search
         for(int i = 0; i < tlen; i++) {
             binarySearch(s, t[i]);
         }

         System.out.println(count);
    }

    public static void binarySearch(int[] s, int t){
        int hi = 0; int ti = s.length-1; //先頭のインデックス; 末尾のインデックス;
        int p;

        while(hi <= ti) {
            p = (hi + ti) / 2; //探索対象インデックス
            if(s[p] == t) {
                count++;
                break;
            } else if(s[p] < t) {
                hi = p + 1;
                continue;
            } else {
                ti = p - 1;
                continue;
            }
        }

        return;
    }
}

