import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Console {
    static Console instance;
    final BufferedReader reader;

    public static Console getInstance() {
        if (instance == null) {
            instance = new Console();
        }
        return instance;
    }
    
    public Console() {
        reader = new BufferedReader(new InputStreamReader(System.in));
    }

    public int readInt() throws IOException {
        return Integer.parseInt(reader.readLine());
    }

    public int[] readLineNumbers(int n) throws IOException {
        String[] numStrings = reader.readLine().split(" ");
        int[] result = new int[n];
        for (int i = 0;i < n;i++) {
            result[i] = Integer.parseInt(numStrings[i]);
        }
        return result;
    }
    
    public void output(int n) {
        System.out.println(n);
    }
}

public class Main {
    public static void main(String[] args) throws Exception {
        int n = Console.getInstance().readInt();
        int[] S = Console.getInstance().readLineNumbers(n);
        int q = Console.getInstance().readInt();
        int[] T = Console.getInstance().readLineNumbers(q);
        
        int count = 0;
        for (int i = 0;i < q;i++) {
            int t = T[i];
            int min = 0;
            int max = n - 1;

            while (min <= max) {
                int index = (min + max) / 2;
                if (S[index] == t) {
                    count++;
                    break;
                } else if (min == max) {
                    // not found
                    break;
                } else if (S[index] > t) {
                    max = index - 1;
                } else if (S[index] < t) {
                    min = index + 1;
                }
            }
        }

        Console.getInstance().output(count);
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io class Console {
    static Console instance;
    final BufferedReader reader;

    public static Console getInstance() {
        if (instance == null) {
            instance = new Console();
        }
        return instance;
    }
    
    public Console() {
        reader = new BufferedReader(new InputStreamReader(System.in));
    }

    public int readInt() throws IOException {
        return Integer.parseInt(reader.readLine());
    }

    public int[] readLineNumbers(int n) throws IOException {
        String[] numStrings = reader.readLine().split(" ");
        int[] result = new int[n];
        for (int i = 0;i < n;i++) {
            result[i] = Integer.parseInt(numStrings[i]);
        }
        return result;
    }
    
    public void output(int n) {
        System.out.println(n);
    }
} Console static Console instance; instance final BufferedReader reader; reader public static Console getInstance() {
        if (instance == null) {
            instance = new Console();
        }
        return instance;
    } getInstance {
        if (instance == null) {
            instance = new Console();
        }
        return instance;
    } if (instance == null) {
            instance = new Console();
        } instance == null instance null {
            instance = new Console();
        } instance = new Console() instance new Console() return instance; instance public Console() {
        reader = new BufferedReader(new InputStreamReader(System.in));
    } Console {
        reader = new BufferedReader(new InputStreamReader(System.in));
    } reader = new BufferedReader(new InputStreamReader(System.in)) reader new BufferedReader(new InputStreamReader(System.in)) public int readInt() throws IOException {
        return Integer.parseInt(reader.readLine());
    } readInt {
        return Integer.parseInt(reader.readLine());
    } return Integer.parseInt(reader.readLine()); Integer.parseInt(reader.readLine()) Integer.parseInt Integer reader.readLine() reader.readLine reader public int[] readLineNumbers(int n) throws IOException {
        String[] numStrings = reader.readLine().split(" ");
        int[] result = new int[n];
        for (int i = 0;i < n;i++) {
            result[i] = Integer.parseInt(numStrings[i]);
        }
        return result;
    } readLineNumbers {
        String[] numStrings = reader.readLine().split(" ");
        int[] result = new int[n];
        for (int i = 0;i < n;i++) {
            result[i] = Integer.parseInt(numStrings[i]);
        }
        return result;
    } String[] numStrings = reader.readLine().split(" "); numStrings reader.readLine().split(" ") reader.readLine().split reader.readLine() reader.readLine reader " " int[] result = new int[n]; result new int[n] n for (int i = 0;i < n;i++) {
            result[i] = Integer.parseInt(numStrings[i]);
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            result[i] = Integer.parseInt(numStrings[i]);
        } {
            result[i] = Integer.parseInt(numStrings[i]);
        } result[i] = Integer.parseInt(numStrings[i]) result[i] result i Integer.parseInt(numStrings[i]) Integer.parseInt Integer numStrings[i] numStrings i return result; result int n n public void output(int n) {
        System.out.println(n);
    } output {
        System.out.println(n);
    } System.out.println(n) System.out.println System.out System System.out n int n n public class Main {
    public static void main(String[] args) throws Exception {
        int n = Console.getInstance().readInt();
        int[] S = Console.getInstance().readLineNumbers(n);
        int q = Console.getInstance().readInt();
        int[] T = Console.getInstance().readLineNumbers(q);
        
        int count = 0;
        for (int i = 0;i < q;i++) {
            int t = T[i];
            int min = 0;
            int max = n - 1;

            while (min <= max) {
                int index = (min + max) / 2;
                if (S[index] == t) {
                    count++;
                    break;
                } else if (min == max) {
                    // not found
                    break;
                } else if (S[index] > t) {
                    max = index - 1;
                } else if (S[index] < t) {
                    min = index + 1;
                }
            }
        }

        Console.getInstance().output(count);
    }
} Main public static void main(String[] args) throws Exception {
        int n = Console.getInstance().readInt();
        int[] S = Console.getInstance().readLineNumbers(n);
        int q = Console.getInstance().readInt();
        int[] T = Console.getInstance().readLineNumbers(q);
        
        int count = 0;
        for (int i = 0;i < q;i++) {
            int t = T[i];
            int min = 0;
            int max = n - 1;

            while (min <= max) {
                int index = (min + max) / 2;
                if (S[index] == t) {
                    count++;
                    break;
                } else if (min == max) {
                    // not found
                    break;
                } else if (S[index] > t) {
                    max = index - 1;
                } else if (S[index] < t) {
                    min = index + 1;
                }
            }
        }

        Console.getInstance().output(count);
    } main {
        int n = Console.getInstance().readInt();
        int[] S = Console.getInstance().readLineNumbers(n);
        int q = Console.getInstance().readInt();
        int[] T = Console.getInstance().readLineNumbers(q);
        
        int count = 0;
        for (int i = 0;i < q;i++) {
            int t = T[i];
            int min = 0;
            int max = n - 1;

            while (min <= max) {
                int index = (min + max) / 2;
                if (S[index] == t) {
                    count++;
                    break;
                } else if (min == max) {
                    // not found
                    break;
                } else if (S[index] > t) {
                    max = index - 1;
                } else if (S[index] < t) {
                    min = index + 1;
                }
            }
        }

        Console.getInstance().output(count);
    } int n = Console.getInstance().readInt(); n Console.getInstance().readInt() Console.getInstance().readInt Console.getInstance() Console.getInstance Console int[] S = Console.getInstance().readLineNumbers(n); S Console.getInstance().readLineNumbers(n) Console.getInstance().readLineNumbers Console.getInstance() Console.getInstance Console n int q = Console.getInstance().readInt(); q Console.getInstance().readInt() Console.getInstance().readInt Console.getInstance() Console.getInstance Console int[] T = Console.getInstance().readLineNumbers(q); T Console.getInstance().readLineNumbers(q) Console.getInstance().readLineNumbers Console.getInstance() Console.getInstance Console q int count = 0; count 0 for (int i = 0;i < q;i++) {
            int t = T[i];
            int min = 0;
            int max = n - 1;

            while (min <= max) {
                int index = (min + max) / 2;
                if (S[index] == t) {
                    count++;
                    break;
                } else if (min == max) {
                    // not found
                    break;
                } else if (S[index] > t) {
                    max = index - 1;
                } else if (S[index] < t) {
                    min = index + 1;
                }
            }
        } int i = 0; int i = 0; i 0 i < q i q i++ i++ i {
            int t = T[i];
            int min = 0;
            int max = n - 1;

            while (min <= max) {
                int index = (min + max) / 2;
                if (S[index] == t) {
                    count++;
                    break;
                } else if (min == max) {
                    // not found
                    break;
                } else if (S[index] > t) {
                    max = index - 1;
                } else if (S[index] < t) {
                    min = index + 1;
                }
            }
        } {
            int t = T[i];
            int min = 0;
            int max = n - 1;

            while (min <= max) {
                int index = (min + max) / 2;
                if (S[index] == t) {
                    count++;
                    break;
                } else if (min == max) {
                    // not found
                    break;
                } else if (S[index] > t) {
                    max = index - 1;
                } else if (S[index] < t) {
                    min = index + 1;
                }
            }
        } int t = T[i]; t T[i] T i int min = 0; min 0 int max = n - 1; max n - 1 n 1 while (min <= max) {
                int index = (min + max) / 2;
                if (S[index] == t) {
                    count++;
                    break;
                } else if (min == max) {
                    // not found
                    break;
                } else if (S[index] > t) {
                    max = index - 1;
                } else if (S[index] < t) {
                    min = index + 1;
                }
            } min <= max min max {
                int index = (min + max) / 2;
                if (S[index] == t) {
                    count++;
                    break;
                } else if (min == max) {
                    // not found
                    break;
                } else if (S[index] > t) {
                    max = index - 1;
                } else if (S[index] < t) {
                    min = index + 1;
                }
            } int index = (min + max) / 2; index (min + max) / 2 (min + max) min max 2 if (S[index] == t) {
                    count++;
                    break;
                } else if (min == max) {
                    // not found
                    break;
                } else if (S[index] > t) {
                    max = index - 1;
                } else if (S[index] < t) {
                    min = index + 1;
                } S[index] == t S[index] S index t {
                    count++;
                    break;
                } count++ count break; if (min == max) {
                    // not found
                    break;
                } else if (S[index] > t) {
                    max = index - 1;
                } else if (S[index] < t) {
                    min = index + 1;
                } min == max min max {
                    // not found
                    break;
                } break; if (S[index] > t) {
                    max = index - 1;
                } else if (S[index] < t) {
                    min = index + 1;
                } S[index] > t S[index] S index t {
                    max = index - 1;
                } max = index - 1 max index - 1 index 1 if (S[index] < t) {
                    min = index + 1;
                } S[index] < t S[index] S index t {
                    min = index + 1;
                } min = index + 1 min index + 1 index 1 Console.getInstance().output(count) Console.getInstance().output Console.getInstance() Console.getInstance Console count String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        int n = Console.getInstance().readInt();
        int[] S = Console.getInstance().readLineNumbers(n);
        int q = Console.getInstance().readInt();
        int[] T = Console.getInstance().readLineNumbers(q);
        
        int count = 0;
        for (int i = 0;i < q;i++) {
            int t = T[i];
            int min = 0;
            int max = n - 1;

            while (min <= max) {
                int index = (min + max) / 2;
                if (S[index] == t) {
                    count++;
                    break;
                } else if (min == max) {
                    // not found
                    break;
                } else if (S[index] > t) {
                    max = index - 1;
                } else if (S[index] < t) {
                    min = index + 1;
                }
            }
        }

        Console.getInstance().output(count);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        int n = Console.getInstance().readInt();
        int[] S = Console.getInstance().readLineNumbers(n);
        int q = Console.getInstance().readInt();
        int[] T = Console.getInstance().readLineNumbers(q);
        
        int count = 0;
        for (int i = 0;i < q;i++) {
            int t = T[i];
            int min = 0;
            int max = n - 1;

            while (min <= max) {
                int index = (min + max) / 2;
                if (S[index] == t) {
                    count++;
                    break;
                } else if (min == max) {
                    // not found
                    break;
                } else if (S[index] > t) {
                    max = index - 1;
                } else if (S[index] < t) {
                    min = index + 1;
                }
            }
        }

        Console.getInstance().output(count);
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Console {
    static Console instance;
    final BufferedReader reader;

    public static Console getInstance() {
        if (instance == null) {
            instance = new Console();
        }
        return instance;
    }
    
    public Console() {
        reader = new BufferedReader(new InputStreamReader(System.in));
    }

    public int readInt() throws IOException {
        return Integer.parseInt(reader.readLine());
    }

    public int[] readLineNumbers(int n) throws IOException {
        String[] numStrings = reader.readLine().split(" ");
        int[] result = new int[n];
        for (int i = 0;i < n;i++) {
            result[i] = Integer.parseInt(numStrings[i]);
        }
        return result;
    }
    
    public void output(int n) {
        System.out.println(n);
    }
}

public class Main {
    public static void main(String[] args) throws Exception {
        int n = Console.getInstance().readInt();
        int[] S = Console.getInstance().readLineNumbers(n);
        int q = Console.getInstance().readInt();
        int[] T = Console.getInstance().readLineNumbers(q);
        
        int count = 0;
        for (int i = 0;i < q;i++) {
            int t = T[i];
            int min = 0;
            int max = n - 1;

            while (min <= max) {
                int index = (min + max) / 2;
                if (S[index] == t) {
                    count++;
                    break;
                } else if (min == max) {
                    // not found
                    break;
                } else if (S[index] > t) {
                    max = index - 1;
                } else if (S[index] < t) {
                    min = index + 1;
                }
            }
        }

        Console.getInstance().output(count);
    }
}