import java.util.*;

import org.omg.Messaging.SYNC_WITH_TRANSPORT;

public class Main {
    public static void main(String[] args) {
        /*
        n: 5
        S: 1 2 3 4 5 
        q: 3
        T: 3 4 1
        out: 3
        */
        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 ans = 0;
        for (int i = 0; i < q; i++) {
            if(search(sc.nextInt(),n,s))ans++;;
        }
        System.out.println(ans);
    }
    
    static boolean search(int key, int n, int[] s) {
        //iは要素の半分、key以下だったらi-1をさらにその半分、以上だったらn+i/2
        //5 ・・・ 2 
        int left = 0;
        int right = n;
        int mid;
        while (left < right) {
            mid = (int) Math.floor((right + left) / 2.0);
            if (s[mid] == key) {
                return true;
            } else if (key < s[mid]) {
                right = mid;
            } else {
                left = mid + 1;
            }
        }
        return false;
    }
} import java.util.*; util.* java import org.omg.Messaging.SYNC_WITH_TRANSPORT; SYNC_WITH_TRANSPORT org.omg.Messaging public class Main {
    public static void main(String[] args) {
        /*
        n: 5
        S: 1 2 3 4 5 
        q: 3
        T: 3 4 1
        out: 3
        */
        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 ans = 0;
        for (int i = 0; i < q; i++) {
            if(search(sc.nextInt(),n,s))ans++;;
        }
        System.out.println(ans);
    }
    
    static boolean search(int key, int n, int[] s) {
        //iは要素の半分、key以下だったらi-1をさらにその半分、以上だったらn+i/2
        //5 ・・・ 2 
        int left = 0;
        int right = n;
        int mid;
        while (left < right) {
            mid = (int) Math.floor((right + left) / 2.0);
            if (s[mid] == key) {
                return true;
            } else if (key < s[mid]) {
                right = mid;
            } else {
                left = mid + 1;
            }
        }
        return false;
    }
} Main public static void main(String[] args) {
        /*
        n: 5
        S: 1 2 3 4 5 
        q: 3
        T: 3 4 1
        out: 3
        */
        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 ans = 0;
        for (int i = 0; i < q; i++) {
            if(search(sc.nextInt(),n,s))ans++;;
        }
        System.out.println(ans);
    } main {
        /*
        n: 5
        S: 1 2 3 4 5 
        q: 3
        T: 3 4 1
        out: 3
        */
        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 ans = 0;
        for (int i = 0; i < q; i++) {
            if(search(sc.nextInt(),n,s))ans++;;
        }
        System.out.println(ans);
    } 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 ans = 0; ans 0 for (int i = 0; i < q; i++) {
            if(search(sc.nextInt(),n,s))ans++;;
        } int i = 0; int i = 0; i 0 i < q i q i++ i++ i {
            if(search(sc.nextInt(),n,s))ans++;;
        } {
            if(search(sc.nextInt(),n,s))ans++;;
        } if(search(sc.nextInt(),n,s))ans++; search(sc.nextInt(),n,s) search sc.nextInt() sc.nextInt sc n s ans++ ans System.out.println(ans) System.out.println System.out System System.out ans String[] args args static boolean search(int key, int n, int[] s) {
        //iは要素の半分、key以下だったらi-1をさらにその半分、以上だったらn+i/2
        //5 ・・・ 2 
        int left = 0;
        int right = n;
        int mid;
        while (left < right) {
            mid = (int) Math.floor((right + left) / 2.0);
            if (s[mid] == key) {
                return true;
            } else if (key < s[mid]) {
                right = mid;
            } else {
                left = mid + 1;
            }
        }
        return false;
    } search {
        //iは要素の半分、key以下だったらi-1をさらにその半分、以上だったらn+i/2
        //5 ・・・ 2 
        int left = 0;
        int right = n;
        int mid;
        while (left < right) {
            mid = (int) Math.floor((right + left) / 2.0);
            if (s[mid] == key) {
                return true;
            } else if (key < s[mid]) {
                right = mid;
            } else {
                left = mid + 1;
            }
        }
        return false;
    } int left = 0; left 0 int right = n; right n int mid; mid while (left < right) {
            mid = (int) Math.floor((right + left) / 2.0);
            if (s[mid] == key) {
                return true;
            } else if (key < s[mid]) {
                right = mid;
            } else {
                left = mid + 1;
            }
        } left < right left right {
            mid = (int) Math.floor((right + left) / 2.0);
            if (s[mid] == key) {
                return true;
            } else if (key < s[mid]) {
                right = mid;
            } else {
                left = mid + 1;
            }
        } mid = (int) Math.floor((right + left) / 2.0) mid (int) Math.floor((right + left) / 2.0) Math.floor Math (right + left) / 2.0 (right + left) right left 2.0 if (s[mid] == key) {
                return true;
            } else if (key < s[mid]) {
                right = mid;
            } else {
                left = mid + 1;
            } s[mid] == key s[mid] s mid key {
                return true;
            } return true; true if (key < s[mid]) {
                right = mid;
            } else {
                left = mid + 1;
            } key < s[mid] key s[mid] s mid {
                right = mid;
            } right = mid right mid {
                left = mid + 1;
            } left = mid + 1 left mid + 1 mid 1 return false; false int key key int n n int[] s s public class Main {
    public static void main(String[] args) {
        /*
        n: 5
        S: 1 2 3 4 5 
        q: 3
        T: 3 4 1
        out: 3
        */
        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 ans = 0;
        for (int i = 0; i < q; i++) {
            if(search(sc.nextInt(),n,s))ans++;;
        }
        System.out.println(ans);
    }
    
    static boolean search(int key, int n, int[] s) {
        //iは要素の半分、key以下だったらi-1をさらにその半分、以上だったらn+i/2
        //5 ・・・ 2 
        int left = 0;
        int right = n;
        int mid;
        while (left < right) {
            mid = (int) Math.floor((right + left) / 2.0);
            if (s[mid] == key) {
                return true;
            } else if (key < s[mid]) {
                right = mid;
            } else {
                left = mid + 1;
            }
        }
        return false;
    }
} public class Main {
    public static void main(String[] args) {
        /*
        n: 5
        S: 1 2 3 4 5 
        q: 3
        T: 3 4 1
        out: 3
        */
        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 ans = 0;
        for (int i = 0; i < q; i++) {
            if(search(sc.nextInt(),n,s))ans++;;
        }
        System.out.println(ans);
    }
    
    static boolean search(int key, int n, int[] s) {
        //iは要素の半分、key以下だったらi-1をさらにその半分、以上だったらn+i/2
        //5 ・・・ 2 
        int left = 0;
        int right = n;
        int mid;
        while (left < right) {
            mid = (int) Math.floor((right + left) / 2.0);
            if (s[mid] == key) {
                return true;
            } else if (key < s[mid]) {
                right = mid;
            } else {
                left = mid + 1;
            }
        }
        return false;
    }
} Main
import java.util.*;

import org.omg.Messaging.SYNC_WITH_TRANSPORT;

public class Main {
    public static void main(String[] args) {
        /*
        n: 5
        S: 1 2 3 4 5 
        q: 3
        T: 3 4 1
        out: 3
        */
        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 ans = 0;
        for (int i = 0; i < q; i++) {
            if(search(sc.nextInt(),n,s))ans++;;
        }
        System.out.println(ans);
    }
    
    static boolean search(int key, int n, int[] s) {
        //iは要素の半分、key以下だったらi-1をさらにその半分、以上だったらn+i/2
        //5 ・・・ 2 
        int left = 0;
        int right = n;
        int mid;
        while (left < right) {
            mid = (int) Math.floor((right + left) / 2.0);
            if (s[mid] == key) {
                return true;
            } else if (key < s[mid]) {
                right = mid;
            } else {
                left = mid + 1;
            }
        }
        return false;
    }
}
