Problem:
Search II

You are given a sequence of n integers S and a sequence of different q integers T. Write a program which outputs C, the number of integers in T which are also in the set S.

Input

In the first line n is given. In the second line, n integers are given. In the third line q is given. Then, in the fourth line, q integers are given.

Output

Print C in a line.

Constraints

Elements in S is sorted in ascending order

n ≤ 100000

q ≤ 50000

0 ≤ an element in S ≤ 109

0 ≤ an element in T ≤ 109

Sample Input 1

5
1 2 3 4 5
3
3 4 1

Sample Output 1

3

Sample Input 2

3
1 2 3
1
5

Sample Output 2

0

Sample Input 3

5
1 1 2 2 3
2
1 2

Sample Output 3

2

Notes

Solution in Rust (judge verdict: Time Limit Exceeded)

use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        //bytesのiterを生成
        .bytes()
        //それをas charでchar型に変換したiterを生成
        .map(|c| c.expect("failed to read char") as char)
        //c.is_whitespace()がfalseになるまで（つまり普通の文字が出るまで）iterを進めたiterを生成
        .skip_while(|c| c.is_whitespace())
        // !c.is_whitespace()がtrue, 即ち（普通の文字の間）iterを進め, 進んだところまでのiterを生成
        .take_while(|c| !c.is_whitespace())
        // それをcollect()してiterからStringを作る
        .collect();
    // parse()で任意の型に変換して返す。
    token.parse().ok().expect("failed to parse token")
}


fn read_one_line_to_vec<T: FromStr>() -> Vec<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let v: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c == &'\x0d' || c == &'\x0a')
        .take_while(|c| !(c == &'\x0d' || c == &'\x0a'))
        .collect();
    v.split_whitespace()
        .map(|c| { let string = c.to_string();
            string.parse::<T>().ok().expect("failed to parse token")})
        .collect()
}

fn main() {
    let _s: u32 = read();
    let targets: Vec<i32> = read_one_line_to_vec();
    let _t_length: u32 = read();
    let search_items: Vec<i32> = read_one_line_to_vec();

    let mut count: i32 = 0;

    for s in search_items {
        let mut left: usize = 0;
        let mut right = targets.len();
        let mut mid = (left + right) / 2;
        while left < right {
            if targets[mid] < s {
                left = mid;
                mid = (left + right) / 2;
            } else if targets[mid] > s {
                right = mid;
                mid = (left + right) / 2;
            } else if targets[mid] == s {
                count += 1;
                break;
            }
        }
    }
    println!("{}", count);
}

/*
fn print_vec(v: Vec<i32>) {
    let mut v_iter = v.iter();
    print!("{}", v_iter.next().as_ref().unwrap());
    for v in v_iter {
        print!(" {}", v)
    }
    println!();
}
*/