import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] S = new int[n];
        for (int i = 0; i < n; i++) {
            S[i] = sc.nextInt();
        }
        int q = sc.nextInt();
        int[] T = new int[q];
        for (int i = 0; i < q; i++) {
            T[i] = sc.nextInt();
        }
        int count = 0;
        Arrays.sort(S);
        Arrays.sort(T);
        int idx = 0;
        for (int i = 0; i < q; i++) {
            for (int j = idx; j < n; j++) {
                if (T[i] == S[j]) {
                    idx = j;
                    count++;
                    break;
                }
            }
        }
        System.out.println(count);
    }
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] S = new int[n];
        for (int i = 0; i < n; i++) {
            S[i] = sc.nextInt();
        }
        int q = sc.nextInt();
        int[] T = new int[q];
        for (int i = 0; i < q; i++) {
            T[i] = sc.nextInt();
        }
        int count = 0;
        Arrays.sort(S);
        Arrays.sort(T);
        int idx = 0;
        for (int i = 0; i < q; i++) {
            for (int j = idx; j < n; j++) {
                if (T[i] == S[j]) {
                    idx = j;
                    count++;
                    break;
                }
            }
        }
        System.out.println(count);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] S = new int[n];
        for (int i = 0; i < n; i++) {
            S[i] = sc.nextInt();
        }
        int q = sc.nextInt();
        int[] T = new int[q];
        for (int i = 0; i < q; i++) {
            T[i] = sc.nextInt();
        }
        int count = 0;
        Arrays.sort(S);
        Arrays.sort(T);
        int idx = 0;
        for (int i = 0; i < q; i++) {
            for (int j = idx; j < n; j++) {
                if (T[i] == S[j]) {
                    idx = j;
                    count++;
                    break;
                }
            }
        }
        System.out.println(count);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] S = new int[n];
        for (int i = 0; i < n; i++) {
            S[i] = sc.nextInt();
        }
        int q = sc.nextInt();
        int[] T = new int[q];
        for (int i = 0; i < q; i++) {
            T[i] = sc.nextInt();
        }
        int count = 0;
        Arrays.sort(S);
        Arrays.sort(T);
        int idx = 0;
        for (int i = 0; i < q; i++) {
            for (int j = idx; j < n; j++) {
                if (T[i] == S[j]) {
                    idx = j;
                    count++;
                    break;
                }
            }
        }
        System.out.println(count);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] S = new int[n]; S new int[n] n for (int i = 0; i < n; i++) {
            S[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            S[i] = sc.nextInt();
        } {
            S[i] = sc.nextInt();
        } S[i] = sc.nextInt() S[i] S i sc.nextInt() sc.nextInt sc int q = sc.nextInt(); q sc.nextInt() sc.nextInt sc int[] T = new int[q]; T new int[q] q for (int i = 0; i < q; i++) {
            T[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < q i q i++ i++ i {
            T[i] = sc.nextInt();
        } {
            T[i] = sc.nextInt();
        } T[i] = sc.nextInt() T[i] T i sc.nextInt() sc.nextInt sc int count = 0; count 0 Arrays.sort(S) Arrays.sort Arrays S Arrays.sort(T) Arrays.sort Arrays T int idx = 0; idx 0 for (int i = 0; i < q; i++) {
            for (int j = idx; j < n; j++) {
                if (T[i] == S[j]) {
                    idx = j;
                    count++;
                    break;
                }
            }
        } int i = 0; int i = 0; i 0 i < q i q i++ i++ i {
            for (int j = idx; j < n; j++) {
                if (T[i] == S[j]) {
                    idx = j;
                    count++;
                    break;
                }
            }
        } {
            for (int j = idx; j < n; j++) {
                if (T[i] == S[j]) {
                    idx = j;
                    count++;
                    break;
                }
            }
        } for (int j = idx; j < n; j++) {
                if (T[i] == S[j]) {
                    idx = j;
                    count++;
                    break;
                }
            } int j = idx; int j = idx; j idx j < n j n j++ j++ j {
                if (T[i] == S[j]) {
                    idx = j;
                    count++;
                    break;
                }
            } {
                if (T[i] == S[j]) {
                    idx = j;
                    count++;
                    break;
                }
            } if (T[i] == S[j]) {
                    idx = j;
                    count++;
                    break;
                } T[i] == S[j] T[i] T i S[j] S j {
                    idx = j;
                    count++;
                    break;
                } idx = j idx j count++ count break; System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] S = new int[n];
        for (int i = 0; i < n; i++) {
            S[i] = sc.nextInt();
        }
        int q = sc.nextInt();
        int[] T = new int[q];
        for (int i = 0; i < q; i++) {
            T[i] = sc.nextInt();
        }
        int count = 0;
        Arrays.sort(S);
        Arrays.sort(T);
        int idx = 0;
        for (int i = 0; i < q; i++) {
            for (int j = idx; j < n; j++) {
                if (T[i] == S[j]) {
                    idx = j;
                    count++;
                    break;
                }
            }
        }
        System.out.println(count);
    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] S = new int[n];
        for (int i = 0; i < n; i++) {
            S[i] = sc.nextInt();
        }
        int q = sc.nextInt();
        int[] T = new int[q];
        for (int i = 0; i < q; i++) {
            T[i] = sc.nextInt();
        }
        int count = 0;
        Arrays.sort(S);
        Arrays.sort(T);
        int idx = 0;
        for (int i = 0; i < q; i++) {
            for (int j = idx; j < n; j++) {
                if (T[i] == S[j]) {
                    idx = j;
                    count++;
                    break;
                }
            }
        }
        System.out.println(count);
    }
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] S = new int[n];
        for (int i = 0; i < n; i++) {
            S[i] = sc.nextInt();
        }
        int q = sc.nextInt();
        int[] T = new int[q];
        for (int i = 0; i < q; i++) {
            T[i] = sc.nextInt();
        }
        int count = 0;
        Arrays.sort(S);
        Arrays.sort(T);
        int idx = 0;
        for (int i = 0; i < q; i++) {
            for (int j = idx; j < n; j++) {
                if (T[i] == S[j]) {
                    idx = j;
                    count++;
                    break;
                }
            }
        }
        System.out.println(count);
    }
}