#include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)< pii; typedef vector vi; typedef vector vll; int N, A, B; int main(){ cin >> N >> A; deque aa(A); rep(i, A)cin >> aa[i]; cin >> B; deque bb(B); rep(i, B)cin >> bb[i]; sort(all(aa)); sort(all(bb), greater()); int ans = 0; deque aaa, bbb; rep(i, N){ if(!sz(aaa))aaa = aa; if(!sz(bbb))bbb = bb; bool win = false; rep(i, sz(aaa)){ rep(j, sz(bbb)){ if(aaa[i] > bbb[j]){ win = true; ans++; aaa.erase(aaa.begin() + i); bbb.erase(bbb.begin() + j); break; } } if(win)break; } if(!win){ aaa.pop_front(); bbb.pop_front(); } } cout << ans << endl; }