import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    static final int INF = 1000000000;     
    
    public static void main(String[] args) throws Exception {                
        Scanner input = new Scanner(System.in);
        int n, q;
        n = input.nextInt();
        ArrayList<Integer> s = new ArrayList<Integer>();
        for (int i = 0; i < n; ++i) {
            int x = input.nextInt();
            if (s.size() > 0 && x == s.get(s.size() - 1)) continue;
            s.add(x);
        }
        q = input.nextInt();
        ArrayList<Integer> t = new ArrayList<Integer>();
        for (int i = 0; i < q; ++i) {
            int x = input.nextInt();
            t.add(x);
        }
        s.retainAll(t);
        System.out.println(s.size());
    }                
} import java.util.*; util.* java import java.io.*; io.* java import java.lang.*; lang.* java public class Main {
    static final int INF = 1000000000;     
    
    public static void main(String[] args) throws Exception {                
        Scanner input = new Scanner(System.in);
        int n, q;
        n = input.nextInt();
        ArrayList<Integer> s = new ArrayList<Integer>();
        for (int i = 0; i < n; ++i) {
            int x = input.nextInt();
            if (s.size() > 0 && x == s.get(s.size() - 1)) continue;
            s.add(x);
        }
        q = input.nextInt();
        ArrayList<Integer> t = new ArrayList<Integer>();
        for (int i = 0; i < q; ++i) {
            int x = input.nextInt();
            t.add(x);
        }
        s.retainAll(t);
        System.out.println(s.size());
    }                
} Main static final int INF = 1000000000; INF 1000000000 public static void main(String[] args) throws Exception {                
        Scanner input = new Scanner(System.in);
        int n, q;
        n = input.nextInt();
        ArrayList<Integer> s = new ArrayList<Integer>();
        for (int i = 0; i < n; ++i) {
            int x = input.nextInt();
            if (s.size() > 0 && x == s.get(s.size() - 1)) continue;
            s.add(x);
        }
        q = input.nextInt();
        ArrayList<Integer> t = new ArrayList<Integer>();
        for (int i = 0; i < q; ++i) {
            int x = input.nextInt();
            t.add(x);
        }
        s.retainAll(t);
        System.out.println(s.size());
    } main {                
        Scanner input = new Scanner(System.in);
        int n, q;
        n = input.nextInt();
        ArrayList<Integer> s = new ArrayList<Integer>();
        for (int i = 0; i < n; ++i) {
            int x = input.nextInt();
            if (s.size() > 0 && x == s.get(s.size() - 1)) continue;
            s.add(x);
        }
        q = input.nextInt();
        ArrayList<Integer> t = new ArrayList<Integer>();
        for (int i = 0; i < q; ++i) {
            int x = input.nextInt();
            t.add(x);
        }
        s.retainAll(t);
        System.out.println(s.size());
    } Scanner input = new Scanner(System.in); input new Scanner(System.in) int n n q; q n = input.nextInt() n input.nextInt() input.nextInt input ArrayList<Integer> s = new ArrayList<Integer>(); s new ArrayList<Integer>() for (int i = 0; i < n; ++i) {
            int x = input.nextInt();
            if (s.size() > 0 && x == s.get(s.size() - 1)) continue;
            s.add(x);
        } int i = 0; int i = 0; i 0 i < n i n ++i ++i i {
            int x = input.nextInt();
            if (s.size() > 0 && x == s.get(s.size() - 1)) continue;
            s.add(x);
        } {
            int x = input.nextInt();
            if (s.size() > 0 && x == s.get(s.size() - 1)) continue;
            s.add(x);
        } int x = input.nextInt(); x input.nextInt() input.nextInt input if (s.size() > 0 && x == s.get(s.size() - 1)) continue; s.size() > 0 && x == s.get(s.size() - 1) s.size() > 0 s.size() s.size s 0 x == s.get(s.size() - 1) x s.get(s.size() - 1) s.get s s.size() - 1 s.size() s.size s 1 continue; s.add(x) s.add s x q = input.nextInt() q input.nextInt() input.nextInt input ArrayList<Integer> t = new ArrayList<Integer>(); t new ArrayList<Integer>() for (int i = 0; i < q; ++i) {
            int x = input.nextInt();
            t.add(x);
        } int i = 0; int i = 0; i 0 i < q i q ++i ++i i {
            int x = input.nextInt();
            t.add(x);
        } {
            int x = input.nextInt();
            t.add(x);
        } int x = input.nextInt(); x input.nextInt() input.nextInt input t.add(x) t.add t x s.retainAll(t) s.retainAll s t System.out.println(s.size()) System.out.println System.out System System.out s.size() s.size s String[] args args public class Main {
    static final int INF = 1000000000;     
    
    public static void main(String[] args) throws Exception {                
        Scanner input = new Scanner(System.in);
        int n, q;
        n = input.nextInt();
        ArrayList<Integer> s = new ArrayList<Integer>();
        for (int i = 0; i < n; ++i) {
            int x = input.nextInt();
            if (s.size() > 0 && x == s.get(s.size() - 1)) continue;
            s.add(x);
        }
        q = input.nextInt();
        ArrayList<Integer> t = new ArrayList<Integer>();
        for (int i = 0; i < q; ++i) {
            int x = input.nextInt();
            t.add(x);
        }
        s.retainAll(t);
        System.out.println(s.size());
    }                
} public class Main {
    static final int INF = 1000000000;     
    
    public static void main(String[] args) throws Exception {                
        Scanner input = new Scanner(System.in);
        int n, q;
        n = input.nextInt();
        ArrayList<Integer> s = new ArrayList<Integer>();
        for (int i = 0; i < n; ++i) {
            int x = input.nextInt();
            if (s.size() > 0 && x == s.get(s.size() - 1)) continue;
            s.add(x);
        }
        q = input.nextInt();
        ArrayList<Integer> t = new ArrayList<Integer>();
        for (int i = 0; i < q; ++i) {
            int x = input.nextInt();
            t.add(x);
        }
        s.retainAll(t);
        System.out.println(s.size());
    }                
} Main
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    static final int INF = 1000000000;     
    
    public static void main(String[] args) throws Exception {                
        Scanner input = new Scanner(System.in);
        int n, q;
        n = input.nextInt();
        ArrayList<Integer> s = new ArrayList<Integer>();
        for (int i = 0; i < n; ++i) {
            int x = input.nextInt();
            if (s.size() > 0 && x == s.get(s.size() - 1)) continue;
            s.add(x);
        }
        q = input.nextInt();
        ArrayList<Integer> t = new ArrayList<Integer>();
        for (int i = 0; i < q; ++i) {
            int x = input.nextInt();
            t.add(x);
        }
        s.retainAll(t);
        System.out.println(s.size());
    }                
}