import java.io.*;

class Main{
        static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        public static void main(String[] args) throws IOException{
                int n1 = Integer.parseInt(br.readLine());
                int[] a1 = new int[n1];
                String[] s1 = br.readLine().split(" ");
                for(int i=0; i<n1; i++)
                        a1[i] =  Integer.parseInt(s1[i]);
                int n2 = Integer.parseInt(br.readLine());
                int[] a2 = new int[n2];
                String[] s2 = br.readLine().split(" ");
                for(int i=0; i<n2; i++)
                        a2[i] = Integer.parseInt(s2[i]);

                int ans = 0;
                for(int i: a2){
                        int l = 0;
                        int r = n1;
                        int m = (r-l)/2;
                        while (r>l+1){
                                if(a1[m] == i){
                                        ans++;
                                        break;
                                }
                                if(a1[m]>i)
                                        r=m;
                                else
                                        l=m;
                                m=(r+l)/2;
                        }
                }
                System.out.println(ans);
        }
} import java.io.*; io.* java class Main{
        static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        public static void main(String[] args) throws IOException{
                int n1 = Integer.parseInt(br.readLine());
                int[] a1 = new int[n1];
                String[] s1 = br.readLine().split(" ");
                for(int i=0; i<n1; i++)
                        a1[i] =  Integer.parseInt(s1[i]);
                int n2 = Integer.parseInt(br.readLine());
                int[] a2 = new int[n2];
                String[] s2 = br.readLine().split(" ");
                for(int i=0; i<n2; i++)
                        a2[i] = Integer.parseInt(s2[i]);

                int ans = 0;
                for(int i: a2){
                        int l = 0;
                        int r = n1;
                        int m = (r-l)/2;
                        while (r>l+1){
                                if(a1[m] == i){
                                        ans++;
                                        break;
                                }
                                if(a1[m]>i)
                                        r=m;
                                else
                                        l=m;
                                m=(r+l)/2;
                        }
                }
                System.out.println(ans);
        }
} Main static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) public static void main(String[] args) throws IOException{
                int n1 = Integer.parseInt(br.readLine());
                int[] a1 = new int[n1];
                String[] s1 = br.readLine().split(" ");
                for(int i=0; i<n1; i++)
                        a1[i] =  Integer.parseInt(s1[i]);
                int n2 = Integer.parseInt(br.readLine());
                int[] a2 = new int[n2];
                String[] s2 = br.readLine().split(" ");
                for(int i=0; i<n2; i++)
                        a2[i] = Integer.parseInt(s2[i]);

                int ans = 0;
                for(int i: a2){
                        int l = 0;
                        int r = n1;
                        int m = (r-l)/2;
                        while (r>l+1){
                                if(a1[m] == i){
                                        ans++;
                                        break;
                                }
                                if(a1[m]>i)
                                        r=m;
                                else
                                        l=m;
                                m=(r+l)/2;
                        }
                }
                System.out.println(ans);
        } main {
                int n1 = Integer.parseInt(br.readLine());
                int[] a1 = new int[n1];
                String[] s1 = br.readLine().split(" ");
                for(int i=0; i<n1; i++)
                        a1[i] =  Integer.parseInt(s1[i]);
                int n2 = Integer.parseInt(br.readLine());
                int[] a2 = new int[n2];
                String[] s2 = br.readLine().split(" ");
                for(int i=0; i<n2; i++)
                        a2[i] = Integer.parseInt(s2[i]);

                int ans = 0;
                for(int i: a2){
                        int l = 0;
                        int r = n1;
                        int m = (r-l)/2;
                        while (r>l+1){
                                if(a1[m] == i){
                                        ans++;
                                        break;
                                }
                                if(a1[m]>i)
                                        r=m;
                                else
                                        l=m;
                                m=(r+l)/2;
                        }
                }
                System.out.println(ans);
        } int n1 = Integer.parseInt(br.readLine()); n1 Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br int[] a1 = new int[n1]; a1 new int[n1] n1 String[] s1 = br.readLine().split(" "); s1 br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " for(int i=0; i<n1; i++)
                        a1[i] =  Integer.parseInt(s1[i]); int i=0; int i=0; i 0 i<n1 i n1 i++ i++ i a1[i] =  Integer.parseInt(s1[i]); a1[i] =  Integer.parseInt(s1[i]) a1[i] a1 i Integer.parseInt(s1[i]) Integer.parseInt Integer s1[i] s1 i int n2 = Integer.parseInt(br.readLine()); n2 Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br int[] a2 = new int[n2]; a2 new int[n2] n2 String[] s2 = br.readLine().split(" "); s2 br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " for(int i=0; i<n2; i++)
                        a2[i] = Integer.parseInt(s2[i]); int i=0; int i=0; i 0 i<n2 i n2 i++ i++ i a2[i] = Integer.parseInt(s2[i]); a2[i] = Integer.parseInt(s2[i]) a2[i] a2 i Integer.parseInt(s2[i]) Integer.parseInt Integer s2[i] s2 i int ans = 0; ans 0 for(int i: a2){
                        int l = 0;
                        int r = n1;
                        int m = (r-l)/2;
                        while (r>l+1){
                                if(a1[m] == i){
                                        ans++;
                                        break;
                                }
                                if(a1[m]>i)
                                        r=m;
                                else
                                        l=m;
                                m=(r+l)/2;
                        }
                } int i a2 {
                        int l = 0;
                        int r = n1;
                        int m = (r-l)/2;
                        while (r>l+1){
                                if(a1[m] == i){
                                        ans++;
                                        break;
                                }
                                if(a1[m]>i)
                                        r=m;
                                else
                                        l=m;
                                m=(r+l)/2;
                        }
                } {
                        int l = 0;
                        int r = n1;
                        int m = (r-l)/2;
                        while (r>l+1){
                                if(a1[m] == i){
                                        ans++;
                                        break;
                                }
                                if(a1[m]>i)
                                        r=m;
                                else
                                        l=m;
                                m=(r+l)/2;
                        }
                } int l = 0; l 0 int r = n1; r n1 int m = (r-l)/2; m (r-l)/2 (r-l) r l 2 while (r>l+1){
                                if(a1[m] == i){
                                        ans++;
                                        break;
                                }
                                if(a1[m]>i)
                                        r=m;
                                else
                                        l=m;
                                m=(r+l)/2;
                        } r>l+1 r l+1 l 1 {
                                if(a1[m] == i){
                                        ans++;
                                        break;
                                }
                                if(a1[m]>i)
                                        r=m;
                                else
                                        l=m;
                                m=(r+l)/2;
                        } if(a1[m] == i){
                                        ans++;
                                        break;
                                } a1[m] == i a1[m] a1 m i {
                                        ans++;
                                        break;
                                } ans++ ans break; if(a1[m]>i)
                                        r=m;
                                else
                                        l=m; a1[m]>i a1[m] a1 m i r=m r m l=m l m m=(r+l)/2 m (r+l)/2 (r+l) r l 2 System.out.println(ans) System.out.println System.out System System.out ans String[] args args
import java.io.*;

class Main{
        static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        public static void main(String[] args) throws IOException{
                int n1 = Integer.parseInt(br.readLine());
                int[] a1 = new int[n1];
                String[] s1 = br.readLine().split(" ");
                for(int i=0; i<n1; i++)
                        a1[i] =  Integer.parseInt(s1[i]);
                int n2 = Integer.parseInt(br.readLine());
                int[] a2 = new int[n2];
                String[] s2 = br.readLine().split(" ");
                for(int i=0; i<n2; i++)
                        a2[i] = Integer.parseInt(s2[i]);

                int ans = 0;
                for(int i: a2){
                        int l = 0;
                        int r = n1;
                        int m = (r-l)/2;
                        while (r>l+1){
                                if(a1[m] == i){
                                        ans++;
                                        break;
                                }
                                if(a1[m]>i)
                                        r=m;
                                else
                                        l=m;
                                m=(r+l)/2;
                        }
                }
                System.out.println(ans);
        }
}