#include <bits/stdc++.h>
using namespace std;
int func(vector<int> &need,vector<int> weight){
sort(need.begin(),need.end(),less<int>());
sort(weight.begin(),weight.end(),less<int>());
int sz1 = need.size(),sz2 = weight.size();
int i = 0,j = 0,cnt = 0;
for(i = 0;i<sz1;++i){
while(j < sz2 && weight[j] < need[i])
++j;
if(j < sz2){
++cnt;
++j;
}
else
break;
}
return cnt;
}
int main(){
int n,m;
cin >> n;
vector<int> need(n);
for(auto i=0;i<n;++i)
cin>>need[i];
cin>>m;
vector<int> weight(m);
for(auto i =0;i<m;++i)
cin>>weight[i];
cout<<func(need,weight)<<endl;
return 0;
}