<?php
$fline = trim(fgets(STDIN));
$fnum = trim(fgets(STDIN));
$farray = explode(' ',$fnum);
$sline = trim(fgets(STDIN));
$snum = trim(fgets(STDIN));
$sarray = explode(' ',$snum);
$scount = 0;

foreach ($sarray as $skey => $svalue) {
    foreach ($farray as $fkey => $fvalue) {
        if ($svalue == $fvalue) {
            $scount++;
            break;
        }
    }
}
echo $scount;
?>