
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 + 1];
        for (int i = 0; i < n; i++) {
            s[i] = sc.nextInt();
        }

        int q     = sc.nextInt();
        int count = 0;
        
        for (int i = 0; i < q; i++) {
            int target = sc.nextInt();
            int left = 0;
            int right = n - 1;
            while (right - left >= 0) {
                int mid = (left + right) / 2;
                if (s[mid] > target) {
                    right = mid - 1;
                } else if (s[mid] < target) {
                    left = mid + 1;
                } else {
                    count++;
                    break;
                }
            }
        }
        System.out.println(count);
    }
} 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 + 1];
        for (int i = 0; i < n; i++) {
            s[i] = sc.nextInt();
        }

        int q     = sc.nextInt();
        int count = 0;
        
        for (int i = 0; i < q; i++) {
            int target = sc.nextInt();
            int left = 0;
            int right = n - 1;
            while (right - left >= 0) {
                int mid = (left + right) / 2;
                if (s[mid] > target) {
                    right = mid - 1;
                } else if (s[mid] < target) {
                    left = mid + 1;
                } else {
                    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 + 1];
        for (int i = 0; i < n; i++) {
            s[i] = sc.nextInt();
        }

        int q     = sc.nextInt();
        int count = 0;
        
        for (int i = 0; i < q; i++) {
            int target = sc.nextInt();
            int left = 0;
            int right = n - 1;
            while (right - left >= 0) {
                int mid = (left + right) / 2;
                if (s[mid] > target) {
                    right = mid - 1;
                } else if (s[mid] < target) {
                    left = mid + 1;
                } else {
                    count++;
                    break;
                }
            }
        }
        System.out.println(count);
    } main {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] s = new int[n + 1];
        for (int i = 0; i < n; i++) {
            s[i] = sc.nextInt();
        }

        int q     = sc.nextInt();
        int count = 0;
        
        for (int i = 0; i < q; i++) {
            int target = sc.nextInt();
            int left = 0;
            int right = n - 1;
            while (right - left >= 0) {
                int mid = (left + right) / 2;
                if (s[mid] > target) {
                    right = mid - 1;
                } else if (s[mid] < target) {
                    left = mid + 1;
                } else {
                    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 + 1]; s new int[n + 1] n + 1 n 1 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 count = 0; count 0 for (int i = 0; i < q; i++) {
            int target = sc.nextInt();
            int left = 0;
            int right = n - 1;
            while (right - left >= 0) {
                int mid = (left + right) / 2;
                if (s[mid] > target) {
                    right = mid - 1;
                } else if (s[mid] < target) {
                    left = mid + 1;
                } else {
                    count++;
                    break;
                }
            }
        } int i = 0; int i = 0; i 0 i < q i q i++ i++ i {
            int target = sc.nextInt();
            int left = 0;
            int right = n - 1;
            while (right - left >= 0) {
                int mid = (left + right) / 2;
                if (s[mid] > target) {
                    right = mid - 1;
                } else if (s[mid] < target) {
                    left = mid + 1;
                } else {
                    count++;
                    break;
                }
            }
        } {
            int target = sc.nextInt();
            int left = 0;
            int right = n - 1;
            while (right - left >= 0) {
                int mid = (left + right) / 2;
                if (s[mid] > target) {
                    right = mid - 1;
                } else if (s[mid] < target) {
                    left = mid + 1;
                } else {
                    count++;
                    break;
                }
            }
        } int target = sc.nextInt(); target sc.nextInt() sc.nextInt sc int left = 0; left 0 int right = n - 1; right n - 1 n 1 while (right - left >= 0) {
                int mid = (left + right) / 2;
                if (s[mid] > target) {
                    right = mid - 1;
                } else if (s[mid] < target) {
                    left = mid + 1;
                } else {
                    count++;
                    break;
                }
            } right - left >= 0 right - left right left 0 {
                int mid = (left + right) / 2;
                if (s[mid] > target) {
                    right = mid - 1;
                } else if (s[mid] < target) {
                    left = mid + 1;
                } else {
                    count++;
                    break;
                }
            } int mid = (left + right) / 2; mid (left + right) / 2 (left + right) left right 2 if (s[mid] > target) {
                    right = mid - 1;
                } else if (s[mid] < target) {
                    left = mid + 1;
                } else {
                    count++;
                    break;
                } s[mid] > target s[mid] s mid target {
                    right = mid - 1;
                } right = mid - 1 right mid - 1 mid 1 if (s[mid] < target) {
                    left = mid + 1;
                } else {
                    count++;
                    break;
                } s[mid] < target s[mid] s mid target {
                    left = mid + 1;
                } left = mid + 1 left mid + 1 mid 1 {
                    count++;
                    break;
                } 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 + 1];
        for (int i = 0; i < n; i++) {
            s[i] = sc.nextInt();
        }

        int q     = sc.nextInt();
        int count = 0;
        
        for (int i = 0; i < q; i++) {
            int target = sc.nextInt();
            int left = 0;
            int right = n - 1;
            while (right - left >= 0) {
                int mid = (left + right) / 2;
                if (s[mid] > target) {
                    right = mid - 1;
                } else if (s[mid] < target) {
                    left = mid + 1;
                } else {
                    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 + 1];
        for (int i = 0; i < n; i++) {
            s[i] = sc.nextInt();
        }

        int q     = sc.nextInt();
        int count = 0;
        
        for (int i = 0; i < q; i++) {
            int target = sc.nextInt();
            int left = 0;
            int right = n - 1;
            while (right - left >= 0) {
                int mid = (left + right) / 2;
                if (s[mid] > target) {
                    right = mid - 1;
                } else if (s[mid] < target) {
                    left = mid + 1;
                } else {
                    count++;
                    break;
                }
            }
        }
        System.out.println(count);
    }
} Main

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 + 1];
        for (int i = 0; i < n; i++) {
            s[i] = sc.nextInt();
        }

        int q     = sc.nextInt();
        int count = 0;
        
        for (int i = 0; i < q; i++) {
            int target = sc.nextInt();
            int left = 0;
            int right = n - 1;
            while (right - left >= 0) {
                int mid = (left + right) / 2;
                if (s[mid] > target) {
                    right = mid - 1;
                } else if (s[mid] < target) {
                    left = mid + 1;
                } else {
                    count++;
                    break;
                }
            }
        }
        System.out.println(count);
    }
}
