let inputStr = '';

process.stdin.on('data', (input) => {inputStr += input;});

process.stdin.on('end', () => {
  const arr = inputStr.split('\n');
  search(arr[1].split(' '), arr[3].split(' '));
});

const search = (a, b) => {
  const base = a.length > b.length ? b : a;
  const target = a.length > b.length ? a : b;
  
  let match = 0;

  base.forEach((baseChar) => {
    for (let i=0; i<target.length; i++) {
      if (target[i] === baseChar) {
        match++;
        return;
      }
    }
  });

  console.log(match);
};
