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: Accepted)

use std::cmp::Ordering;

fn binary_seatch(arr: &Vec<i32>, target: i32) -> Option<u32> {
    let n = arr.len();

    if n <= 0 {
        return None;
    }

    let i_center = n / 2;
    let s_center = arr[i_center];

    match s_center.cmp(&target) {
        Ordering::Less => binary_seatch(&arr[(i_center + 1)..n].to_vec(), target),
        Ordering::Equal => Some(i_center as u32),
        Ordering::Greater => binary_seatch(&arr[0..i_center].to_vec(), target),
    }
}

fn evaluate(inputs_s: Vec<i32>, inputs_t: Vec<i32>) {
    let mut n = 0;
    for &t in &inputs_t {
        match binary_seatch(&inputs_s, t) {
            Some(_) => n += 1,
            None => (),
        }
    }
    println!("{}", n);
}

fn main() {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).ok();

    let mut line = String::new();
    std::io::stdin().read_line(&mut line).ok();
    let inputs_s: Vec<i32> = line.split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect();

    let mut line = String::new();
    std::io::stdin().read_line(&mut line).ok();

    let mut line = String::new();
    std::io::stdin().read_line(&mut line).ok();
    let inputs_t: Vec<i32> = line.split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect();

    // println!("{:?}", inputs_s);
    // println!("{:?}", inputs_t);

    evaluate(inputs_s, inputs_t);
}