#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair i_i; typedef pair ll_i; typedef pair d_i; typedef pair ll_ll; typedef pair d_d; struct edge { int u, v; ll w; }; ll MOD = 1000000007; ll _MOD = 1000000009; double EPS = 1e-10; int f(vector a, vector b) { int l = 0; for (int k = 0; ; k++) { int i; for (i = 0; i < a.size() && a[i] <= l; i++); if (i == a.size()) return k; l = a[i]; swap(a, b); } } int main() { int n; cin >> n; vector a(n); for (int i = 0; i < n; i++) cin >> a[i]; sort(a.begin(), a.end()); int m; cin >> m; vector b(m); for (int j = 0; j < m; j++) cin >> b[j]; sort(b.begin(), b.end()); cout << max(f(a, b), f(b, a)) << endl; }