import java.util.*;
import java.io.*;

class Main{
    static int binarySearch(int[] tempArray, int n, int key){
        int left = 0;
        int right = n;

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

    public static void main(String[] args){
        int count;
        int[] array1;
        int[] array2;
        int[] array3;
        int flag = 0;

        try{
            Scanner scan = new Scanner(System.in);
            String str = scan.next();

            count = Integer.parseInt(str);

            if(count > 100000){
                throw new Exception("ERROE");
            }
            array1 = new int[count];
            array3 = new int[count];

            for(int i = 0; i < array1.length; i++){
                str = scan.next();
                array1[i] = Integer.parseInt(str);
            }

            str = scan.next();
            count = Integer.parseInt(str);

            if(count > 50000){
                throw new Exception("ERROE");
            }
            array2 = new int[count];
            for(int i = 0; i < array2.length; i++){
                str = scan.next();
                array2[i] = Integer.parseInt(str);
            }


            //配列の確認部分
            // for(int i = 0; i < array1.length; i++){
            //     System.out.print(array1[i] + " ");
            // }
            // System.out.println();
            // for(int i = 0; i < array2.length; i++){
            //     System.out.print(array2[i] + " ");
            // }
            // System.out.println();

            //線形探索
            // count = 0;
            // for(int i = 0; i < array2.length; i++){
            //     for(int j = 0; j < array1.length; j++){
            //         flag = 0;
            //         if(array2[i] == array1[j]){
            //             for(int k = 0; k < count; k++){
            //                 if(array2[i] == array3[k]){
            //                     flag = -1;
            //                     break;
            //                 }
            //             }
            //             if(flag != -1){
            //                 array3[count] = array2[i];
            //                 count++;
            //             }
            //         }
            //     }
            // }

            count = 0;
            for(int i = 0; i < array2.length; i++){
                count +=  binarySearch(array1, array1.length, array2[i]);
            }

            System.out.println(count);

        }catch(Exception e){
            System.out.println("ERROR");
        }

    }
}
 import java.util.*; util.* java import java.io.*; io.* java class Main{
    static int binarySearch(int[] tempArray, int n, int key){
        int left = 0;
        int right = n;

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

    public static void main(String[] args){
        int count;
        int[] array1;
        int[] array2;
        int[] array3;
        int flag = 0;

        try{
            Scanner scan = new Scanner(System.in);
            String str = scan.next();

            count = Integer.parseInt(str);

            if(count > 100000){
                throw new Exception("ERROE");
            }
            array1 = new int[count];
            array3 = new int[count];

            for(int i = 0; i < array1.length; i++){
                str = scan.next();
                array1[i] = Integer.parseInt(str);
            }

            str = scan.next();
            count = Integer.parseInt(str);

            if(count > 50000){
                throw new Exception("ERROE");
            }
            array2 = new int[count];
            for(int i = 0; i < array2.length; i++){
                str = scan.next();
                array2[i] = Integer.parseInt(str);
            }


            //配列の確認部分
            // for(int i = 0; i < array1.length; i++){
            //     System.out.print(array1[i] + " ");
            // }
            // System.out.println();
            // for(int i = 0; i < array2.length; i++){
            //     System.out.print(array2[i] + " ");
            // }
            // System.out.println();

            //線形探索
            // count = 0;
            // for(int i = 0; i < array2.length; i++){
            //     for(int j = 0; j < array1.length; j++){
            //         flag = 0;
            //         if(array2[i] == array1[j]){
            //             for(int k = 0; k < count; k++){
            //                 if(array2[i] == array3[k]){
            //                     flag = -1;
            //                     break;
            //                 }
            //             }
            //             if(flag != -1){
            //                 array3[count] = array2[i];
            //                 count++;
            //             }
            //         }
            //     }
            // }

            count = 0;
            for(int i = 0; i < array2.length; i++){
                count +=  binarySearch(array1, array1.length, array2[i]);
            }

            System.out.println(count);

        }catch(Exception e){
            System.out.println("ERROR");
        }

    }
} Main static int binarySearch(int[] tempArray, int n, int key){
        int left = 0;
        int right = n;

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

        while(left < right){
            int mid = (left + right) / 2;
            if(tempArray[mid] == key){
                return 1;
            }else if(key < tempArray[mid]){
                right = mid;
            }else{
                left = mid + 1;
            }
        }
        return 0;
    } int left = 0; left 0 int right = n; right n while(left < right){
            int mid = (left + right) / 2;
            if(tempArray[mid] == key){
                return 1;
            }else if(key < tempArray[mid]){
                right = mid;
            }else{
                left = mid + 1;
            }
        } left < right left right {
            int mid = (left + right) / 2;
            if(tempArray[mid] == key){
                return 1;
            }else if(key < tempArray[mid]){
                right = mid;
            }else{
                left = mid + 1;
            }
        } int mid = (left + right) / 2; mid (left + right) / 2 (left + right) left right 2 if(tempArray[mid] == key){
                return 1;
            }else if(key < tempArray[mid]){
                right = mid;
            }else{
                left = mid + 1;
            } tempArray[mid] == key tempArray[mid] tempArray mid key {
                return 1;
            } return 1; 1 if(key < tempArray[mid]){
                right = mid;
            }else{
                left = mid + 1;
            } key < tempArray[mid] key tempArray[mid] tempArray mid {
                right = mid;
            } right = mid right mid {
                left = mid + 1;
            } left = mid + 1 left mid + 1 mid 1 return 0; 0 int[] tempArray tempArray int n n int key key public static void main(String[] args){
        int count;
        int[] array1;
        int[] array2;
        int[] array3;
        int flag = 0;

        try{
            Scanner scan = new Scanner(System.in);
            String str = scan.next();

            count = Integer.parseInt(str);

            if(count > 100000){
                throw new Exception("ERROE");
            }
            array1 = new int[count];
            array3 = new int[count];

            for(int i = 0; i < array1.length; i++){
                str = scan.next();
                array1[i] = Integer.parseInt(str);
            }

            str = scan.next();
            count = Integer.parseInt(str);

            if(count > 50000){
                throw new Exception("ERROE");
            }
            array2 = new int[count];
            for(int i = 0; i < array2.length; i++){
                str = scan.next();
                array2[i] = Integer.parseInt(str);
            }


            //配列の確認部分
            // for(int i = 0; i < array1.length; i++){
            //     System.out.print(array1[i] + " ");
            // }
            // System.out.println();
            // for(int i = 0; i < array2.length; i++){
            //     System.out.print(array2[i] + " ");
            // }
            // System.out.println();

            //線形探索
            // count = 0;
            // for(int i = 0; i < array2.length; i++){
            //     for(int j = 0; j < array1.length; j++){
            //         flag = 0;
            //         if(array2[i] == array1[j]){
            //             for(int k = 0; k < count; k++){
            //                 if(array2[i] == array3[k]){
            //                     flag = -1;
            //                     break;
            //                 }
            //             }
            //             if(flag != -1){
            //                 array3[count] = array2[i];
            //                 count++;
            //             }
            //         }
            //     }
            // }

            count = 0;
            for(int i = 0; i < array2.length; i++){
                count +=  binarySearch(array1, array1.length, array2[i]);
            }

            System.out.println(count);

        }catch(Exception e){
            System.out.println("ERROR");
        }

    } main {
        int count;
        int[] array1;
        int[] array2;
        int[] array3;
        int flag = 0;

        try{
            Scanner scan = new Scanner(System.in);
            String str = scan.next();

            count = Integer.parseInt(str);

            if(count > 100000){
                throw new Exception("ERROE");
            }
            array1 = new int[count];
            array3 = new int[count];

            for(int i = 0; i < array1.length; i++){
                str = scan.next();
                array1[i] = Integer.parseInt(str);
            }

            str = scan.next();
            count = Integer.parseInt(str);

            if(count > 50000){
                throw new Exception("ERROE");
            }
            array2 = new int[count];
            for(int i = 0; i < array2.length; i++){
                str = scan.next();
                array2[i] = Integer.parseInt(str);
            }


            //配列の確認部分
            // for(int i = 0; i < array1.length; i++){
            //     System.out.print(array1[i] + " ");
            // }
            // System.out.println();
            // for(int i = 0; i < array2.length; i++){
            //     System.out.print(array2[i] + " ");
            // }
            // System.out.println();

            //線形探索
            // count = 0;
            // for(int i = 0; i < array2.length; i++){
            //     for(int j = 0; j < array1.length; j++){
            //         flag = 0;
            //         if(array2[i] == array1[j]){
            //             for(int k = 0; k < count; k++){
            //                 if(array2[i] == array3[k]){
            //                     flag = -1;
            //                     break;
            //                 }
            //             }
            //             if(flag != -1){
            //                 array3[count] = array2[i];
            //                 count++;
            //             }
            //         }
            //     }
            // }

            count = 0;
            for(int i = 0; i < array2.length; i++){
                count +=  binarySearch(array1, array1.length, array2[i]);
            }

            System.out.println(count);

        }catch(Exception e){
            System.out.println("ERROR");
        }

    } int count; count int[] array1; array1 int[] array2; array2 int[] array3; array3 int flag = 0; flag 0 try{
            Scanner scan = new Scanner(System.in);
            String str = scan.next();

            count = Integer.parseInt(str);

            if(count > 100000){
                throw new Exception("ERROE");
            }
            array1 = new int[count];
            array3 = new int[count];

            for(int i = 0; i < array1.length; i++){
                str = scan.next();
                array1[i] = Integer.parseInt(str);
            }

            str = scan.next();
            count = Integer.parseInt(str);

            if(count > 50000){
                throw new Exception("ERROE");
            }
            array2 = new int[count];
            for(int i = 0; i < array2.length; i++){
                str = scan.next();
                array2[i] = Integer.parseInt(str);
            }


            //配列の確認部分
            // for(int i = 0; i < array1.length; i++){
            //     System.out.print(array1[i] + " ");
            // }
            // System.out.println();
            // for(int i = 0; i < array2.length; i++){
            //     System.out.print(array2[i] + " ");
            // }
            // System.out.println();

            //線形探索
            // count = 0;
            // for(int i = 0; i < array2.length; i++){
            //     for(int j = 0; j < array1.length; j++){
            //         flag = 0;
            //         if(array2[i] == array1[j]){
            //             for(int k = 0; k < count; k++){
            //                 if(array2[i] == array3[k]){
            //                     flag = -1;
            //                     break;
            //                 }
            //             }
            //             if(flag != -1){
            //                 array3[count] = array2[i];
            //                 count++;
            //             }
            //         }
            //     }
            // }

            count = 0;
            for(int i = 0; i < array2.length; i++){
                count +=  binarySearch(array1, array1.length, array2[i]);
            }

            System.out.println(count);

        }catch(Exception e){
            System.out.println("ERROR");
        } catch(Exception e){
            System.out.println("ERROR");
        } Exception e {
            System.out.println("ERROR");
        } System.out.println("ERROR") System.out.println System.out System System.out "ERROR" {
            Scanner scan = new Scanner(System.in);
            String str = scan.next();

            count = Integer.parseInt(str);

            if(count > 100000){
                throw new Exception("ERROE");
            }
            array1 = new int[count];
            array3 = new int[count];

            for(int i = 0; i < array1.length; i++){
                str = scan.next();
                array1[i] = Integer.parseInt(str);
            }

            str = scan.next();
            count = Integer.parseInt(str);

            if(count > 50000){
                throw new Exception("ERROE");
            }
            array2 = new int[count];
            for(int i = 0; i < array2.length; i++){
                str = scan.next();
                array2[i] = Integer.parseInt(str);
            }


            //配列の確認部分
            // for(int i = 0; i < array1.length; i++){
            //     System.out.print(array1[i] + " ");
            // }
            // System.out.println();
            // for(int i = 0; i < array2.length; i++){
            //     System.out.print(array2[i] + " ");
            // }
            // System.out.println();

            //線形探索
            // count = 0;
            // for(int i = 0; i < array2.length; i++){
            //     for(int j = 0; j < array1.length; j++){
            //         flag = 0;
            //         if(array2[i] == array1[j]){
            //             for(int k = 0; k < count; k++){
            //                 if(array2[i] == array3[k]){
            //                     flag = -1;
            //                     break;
            //                 }
            //             }
            //             if(flag != -1){
            //                 array3[count] = array2[i];
            //                 count++;
            //             }
            //         }
            //     }
            // }

            count = 0;
            for(int i = 0; i < array2.length; i++){
                count +=  binarySearch(array1, array1.length, array2[i]);
            }

            System.out.println(count);

        } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String str = scan.next(); str scan.next() scan.next scan count = Integer.parseInt(str) count Integer.parseInt(str) Integer.parseInt Integer str if(count > 100000){
                throw new Exception("ERROE");
            } count > 100000 count 100000 {
                throw new Exception("ERROE");
            } throw new Exception("ERROE"); new Exception("ERROE") array1 = new int[count] array1 new int[count] count array3 = new int[count] array3 new int[count] count for(int i = 0; i < array1.length; i++){
                str = scan.next();
                array1[i] = Integer.parseInt(str);
            } int i = 0; int i = 0; i 0 i < array1.length i array1.length array1 array1.length i++ i++ i {
                str = scan.next();
                array1[i] = Integer.parseInt(str);
            } {
                str = scan.next();
                array1[i] = Integer.parseInt(str);
            } str = scan.next() str scan.next() scan.next scan array1[i] = Integer.parseInt(str) array1[i] array1 i Integer.parseInt(str) Integer.parseInt Integer str str = scan.next() str scan.next() scan.next scan count = Integer.parseInt(str) count Integer.parseInt(str) Integer.parseInt Integer str if(count > 50000){
                throw new Exception("ERROE");
            } count > 50000 count 50000 {
                throw new Exception("ERROE");
            } throw new Exception("ERROE"); new Exception("ERROE") array2 = new int[count] array2 new int[count] count for(int i = 0; i < array2.length; i++){
                str = scan.next();
                array2[i] = Integer.parseInt(str);
            } int i = 0; int i = 0; i 0 i < array2.length i array2.length array2 array2.length i++ i++ i {
                str = scan.next();
                array2[i] = Integer.parseInt(str);
            } {
                str = scan.next();
                array2[i] = Integer.parseInt(str);
            } str = scan.next() str scan.next() scan.next scan array2[i] = Integer.parseInt(str) array2[i] array2 i Integer.parseInt(str) Integer.parseInt Integer str count = 0 count 0 for(int i = 0; i < array2.length; i++){
                count +=  binarySearch(array1, array1.length, array2[i]);
            } int i = 0; int i = 0; i 0 i < array2.length i array2.length array2 array2.length i++ i++ i {
                count +=  binarySearch(array1, array1.length, array2[i]);
            } {
                count +=  binarySearch(array1, array1.length, array2[i]);
            } count +=  binarySearch(array1, array1.length, array2[i]) count binarySearch(array1, array1.length, array2[i]) binarySearch array1 array1.length array1 array1.length array2[i] array2 i System.out.println(count) System.out.println System.out System System.out count String[] args args
import java.util.*;
import java.io.*;

class Main{
    static int binarySearch(int[] tempArray, int n, int key){
        int left = 0;
        int right = n;

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

    public static void main(String[] args){
        int count;
        int[] array1;
        int[] array2;
        int[] array3;
        int flag = 0;

        try{
            Scanner scan = new Scanner(System.in);
            String str = scan.next();

            count = Integer.parseInt(str);

            if(count > 100000){
                throw new Exception("ERROE");
            }
            array1 = new int[count];
            array3 = new int[count];

            for(int i = 0; i < array1.length; i++){
                str = scan.next();
                array1[i] = Integer.parseInt(str);
            }

            str = scan.next();
            count = Integer.parseInt(str);

            if(count > 50000){
                throw new Exception("ERROE");
            }
            array2 = new int[count];
            for(int i = 0; i < array2.length; i++){
                str = scan.next();
                array2[i] = Integer.parseInt(str);
            }


            //配列の確認部分
            // for(int i = 0; i < array1.length; i++){
            //     System.out.print(array1[i] + " ");
            // }
            // System.out.println();
            // for(int i = 0; i < array2.length; i++){
            //     System.out.print(array2[i] + " ");
            // }
            // System.out.println();

            //線形探索
            // count = 0;
            // for(int i = 0; i < array2.length; i++){
            //     for(int j = 0; j < array1.length; j++){
            //         flag = 0;
            //         if(array2[i] == array1[j]){
            //             for(int k = 0; k < count; k++){
            //                 if(array2[i] == array3[k]){
            //                     flag = -1;
            //                     break;
            //                 }
            //             }
            //             if(flag != -1){
            //                 array3[count] = array2[i];
            //                 count++;
            //             }
            //         }
            //     }
            // }

            count = 0;
            for(int i = 0; i < array2.length; i++){
                count +=  binarySearch(array1, array1.length, array2[i]);
            }

            System.out.println(count);

        }catch(Exception e){
            System.out.println("ERROR");
        }

    }
}

