const config = {
    input: '/dev/stdin',
    newline: '\n'
};

const line = require('fs').readFileSync(config.input, 'utf-8').split(config.newline);

const bs = (arr, n) => {
    if (arr.length === 0) return false;
    const mid = Math.floor(arr.length / 2);
    const f = arr.slice(0, mid);
    const l = arr.slice(mid+1);
    const midElm = arr[mid];
    if (n === midElm) return true;
    if (n < midElm) {
        return bs(f, n);
    } else {
        return bs(l, n);
    }
};

const solve = (arr1, arr2) => arr2.filter(x => bs(arr1, x)).length;

const data1 = line[1].split(' ').map(x => parseInt(x));
const data2 = line[3].split(' ').map(x => parseInt(x));

console.log(solve(data1, data2));

