// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_B&lang=ja

process.stdin.resume();
process.stdin.setEncoding('utf8');

const buf = []
process.stdin.on('data', function (chunk) {
    buf.push(chunk);
});

process.stdin.on('end', function (chunk) {
    const n = buf.map(x => x.toString()).join("") // 文字列化する
        .split("\n") // \nで分割
        // .map(x => Number(x))
        .filter(x => x !== "");

    [, binary, , serch] = n;

    const data1 = binary.split(" ");
    const b1 = data1.map(x => Number(x));

    const data2 = serch.split(" ").map(x => Number(x));
    let count = 0;

    let middle = 0;
    let left = 0;
    let right = b1.length;
    let tr = true;

    for (let i = 0; i < data2.length; i++) {
        while (tr) {
            middle = ~~((left + right) / 2);
            if (b1[middle] === data2[i]) {
                count += 1;
                tr = false;
            } else if (b1[middle] < data2[i]) {
                left = middle + 1;
            } else if (b1[middle] > data2[i]) {
                right = middle - 1;
            }
            if (right < left || left > right) {
                tr = false;
            }
        }
        tr = true;
        right = b1.length;
        left = 0;
        middle = 0;
    }
    console.log(count);

});

