#include <bits/stdc++.h>
using namespace std;
int main()
{
    freopen ("dempt.inp","r",stdin);
    freopen ("dempt.out","w",stdout);
    int64_t n,m;
    cin>>n;
    int64_t a[n+1];
    for(int64_t i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    cin>>m;
    int64_t b[m+1];
    for(int64_t i=1;i<=m;i++)
    {
        cin>>b[i];
    }
    sort(a+1,a+n+1);
    sort(b+1,b+m+1);
    int64_t k=1;
    int64_t r=0;
    for(int64_t i=1;i<=n;i++)
    {
        for(int64_t j=k;j<=m;j++)
        {
            if(a[i]<b[j])
            {
                break;
            }
            if(a[i]==b[j])
            {
                r++;
                k=j+1;
                break;
            }
        }
    }
    cout<<r;
}
