#include using namespace std; struct Query { int length, type; bool operator<(const Query& q) const { return(length < q.length); } }; int main() { vector< Query > query; for(int i = 0; i < 2; i++) { int N; cin >> N; while(N--) { int Digit; cin >> Digit; query.push_back((Query){Digit, i}); } } sort(query.rbegin(), query.rend()); int height = 0, type = 0, length = 1 << 30; for(int i = 0; i < query.size(); i++) { Query& q = query[i]; if(type != q.type && length > q.length) { height++; type = q.type; length = q.length; } } int height2 = 0; type = 1, length = 1 << 30; for(int i = 0; i < query.size(); i++) { Query& q = query[i]; if(type != q.type && length > q.length) { height2++; type = q.type; length = q.length; } } cout << max(height, height2) << endl; }