#define _CRT_SECURE_NO_WARNINGS
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> ostream & operator<<(ostream & os, vector<T> const &);
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream & os, tuple<T...> const & t){ _ot<0>(os, t); return os; }
template<class T, class U> ostream & operator<<(ostream & os, pair<T,U> const & p){ return os << "(" << p.first << ", " << p.second << ") "; }
template<class T> ostream & operator<<(ostream & os, vector<T> const & v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; }
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<mt(__VA_ARGS__)<<" ["<<__LINE__<<"]"<<endl)
#else
#define dump(...)
#endif

int solve(priority_queue<int> p, priority_queue<int> q){
    int ans = 0;
    int cur = 100000000;
    rep(i,100000000){
        auto & Q = i%2 ? p : q;
        while(Q.size() && Q.top() >= cur) Q.pop();
        if(Q.size() == 0) break;
        cur = Q.top();
        Q.pop();
        ans++;
    }
    return ans;
}

int main(){
    int a,b;
    while(cin>>a){
        priority_queue<int> p,q;
        rep(i,a){
            int x;cin>>x;
            p.push(x);
        }
        cin >> b;
        rep(i,b){
            int x;cin>>x;
            q.push(x);
        }
        cout << max(solve(p,q), solve(q,p)) << endl;
    }
}