import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        int N = sc.nextInt();
                        long[] S = new long[N];
                        for (int i = 0; i < N; i++) {
                                S[i] = sc.nextLong();
                        }
                        int Q = sc.nextInt();
                        long[] T = new long[Q];
                        for (int i = 0; i < Q; i++) {
                                T[i] = sc.nextLong();
                        }
                        Arrays.sort(S);
                        Arrays.sort(T);
                        int ans = 0;
                        for (int i = 0, j = 0; i < N && j < Q; i++) {
                                if (S[i] == T[j]) {
                                        ans++;
                                        j++;
                                } else if(S[i] > T[j]) {
                                        i--;
                                        j++;
                                }
                        }
                        System.out.println(ans);
                }
        }
} import java.util.*; util.* java class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        int N = sc.nextInt();
                        long[] S = new long[N];
                        for (int i = 0; i < N; i++) {
                                S[i] = sc.nextLong();
                        }
                        int Q = sc.nextInt();
                        long[] T = new long[Q];
                        for (int i = 0; i < Q; i++) {
                                T[i] = sc.nextLong();
                        }
                        Arrays.sort(S);
                        Arrays.sort(T);
                        int ans = 0;
                        for (int i = 0, j = 0; i < N && j < Q; i++) {
                                if (S[i] == T[j]) {
                                        ans++;
                                        j++;
                                } else if(S[i] > T[j]) {
                                        i--;
                                        j++;
                                }
                        }
                        System.out.println(ans);
                }
        }
} Main public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        int N = sc.nextInt();
                        long[] S = new long[N];
                        for (int i = 0; i < N; i++) {
                                S[i] = sc.nextLong();
                        }
                        int Q = sc.nextInt();
                        long[] T = new long[Q];
                        for (int i = 0; i < Q; i++) {
                                T[i] = sc.nextLong();
                        }
                        Arrays.sort(S);
                        Arrays.sort(T);
                        int ans = 0;
                        for (int i = 0, j = 0; i < N && j < Q; i++) {
                                if (S[i] == T[j]) {
                                        ans++;
                                        j++;
                                } else if(S[i] > T[j]) {
                                        i--;
                                        j++;
                                }
                        }
                        System.out.println(ans);
                }
        } main {
                try (Scanner sc = new Scanner(System.in)) {
                        int N = sc.nextInt();
                        long[] S = new long[N];
                        for (int i = 0; i < N; i++) {
                                S[i] = sc.nextLong();
                        }
                        int Q = sc.nextInt();
                        long[] T = new long[Q];
                        for (int i = 0; i < Q; i++) {
                                T[i] = sc.nextLong();
                        }
                        Arrays.sort(S);
                        Arrays.sort(T);
                        int ans = 0;
                        for (int i = 0, j = 0; i < N && j < Q; i++) {
                                if (S[i] == T[j]) {
                                        ans++;
                                        j++;
                                } else if(S[i] > T[j]) {
                                        i--;
                                        j++;
                                }
                        }
                        System.out.println(ans);
                }
        } try (Scanner sc = new Scanner(System.in)) {
                        int N = sc.nextInt();
                        long[] S = new long[N];
                        for (int i = 0; i < N; i++) {
                                S[i] = sc.nextLong();
                        }
                        int Q = sc.nextInt();
                        long[] T = new long[Q];
                        for (int i = 0; i < Q; i++) {
                                T[i] = sc.nextLong();
                        }
                        Arrays.sort(S);
                        Arrays.sort(T);
                        int ans = 0;
                        for (int i = 0, j = 0; i < N && j < Q; i++) {
                                if (S[i] == T[j]) {
                                        ans++;
                                        j++;
                                } else if(S[i] > T[j]) {
                                        i--;
                                        j++;
                                }
                        }
                        System.out.println(ans);
                } {
                        int N = sc.nextInt();
                        long[] S = new long[N];
                        for (int i = 0; i < N; i++) {
                                S[i] = sc.nextLong();
                        }
                        int Q = sc.nextInt();
                        long[] T = new long[Q];
                        for (int i = 0; i < Q; i++) {
                                T[i] = sc.nextLong();
                        }
                        Arrays.sort(S);
                        Arrays.sort(T);
                        int ans = 0;
                        for (int i = 0, j = 0; i < N && j < Q; i++) {
                                if (S[i] == T[j]) {
                                        ans++;
                                        j++;
                                } else if(S[i] > T[j]) {
                                        i--;
                                        j++;
                                }
                        }
                        System.out.println(ans);
                } Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc long[] S = new long[N]; S new long[N] N for (int i = 0; i < N; i++) {
                                S[i] = sc.nextLong();
                        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
                                S[i] = sc.nextLong();
                        } {
                                S[i] = sc.nextLong();
                        } S[i] = sc.nextLong() S[i] S i sc.nextLong() sc.nextLong sc int Q = sc.nextInt(); Q sc.nextInt() sc.nextInt sc long[] T = new long[Q]; T new long[Q] Q for (int i = 0; i < Q; i++) {
                                T[i] = sc.nextLong();
                        } int i = 0; int i = 0; i 0 i < Q i Q i++ i++ i {
                                T[i] = sc.nextLong();
                        } {
                                T[i] = sc.nextLong();
                        } T[i] = sc.nextLong() T[i] T i sc.nextLong() sc.nextLong sc Arrays.sort(S) Arrays.sort Arrays S Arrays.sort(T) Arrays.sort Arrays T int ans = 0; ans 0 for (int i = 0, j = 0; i < N && j < Q; i++) {
                                if (S[i] == T[j]) {
                                        ans++;
                                        j++;
                                } else if(S[i] > T[j]) {
                                        i--;
                                        j++;
                                }
                        } int i = 0, j = 0; int i = 0 i 0 j = 0; j 0 i < N && j < Q i < N i N j < Q j Q i++ i++ i {
                                if (S[i] == T[j]) {
                                        ans++;
                                        j++;
                                } else if(S[i] > T[j]) {
                                        i--;
                                        j++;
                                }
                        } {
                                if (S[i] == T[j]) {
                                        ans++;
                                        j++;
                                } else if(S[i] > T[j]) {
                                        i--;
                                        j++;
                                }
                        } if (S[i] == T[j]) {
                                        ans++;
                                        j++;
                                } else if(S[i] > T[j]) {
                                        i--;
                                        j++;
                                } S[i] == T[j] S[i] S i T[j] T j {
                                        ans++;
                                        j++;
                                } ans++ ans j++ j if(S[i] > T[j]) {
                                        i--;
                                        j++;
                                } S[i] > T[j] S[i] S i T[j] T j {
                                        i--;
                                        j++;
                                } i-- i j++ j System.out.println(ans) System.out.println System.out System System.out ans String args[] args
import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        int N = sc.nextInt();
                        long[] S = new long[N];
                        for (int i = 0; i < N; i++) {
                                S[i] = sc.nextLong();
                        }
                        int Q = sc.nextInt();
                        long[] T = new long[Q];
                        for (int i = 0; i < Q; i++) {
                                T[i] = sc.nextLong();
                        }
                        Arrays.sort(S);
                        Arrays.sort(T);
                        int ans = 0;
                        for (int i = 0, j = 0; i < N && j < Q; i++) {
                                if (S[i] == T[j]) {
                                        ans++;
                                        j++;
                                } else if(S[i] > T[j]) {
                                        i--;
                                        j++;
                                }
                        }
                        System.out.println(ans);
                }
        }
}