#include #define FOR(I,X,Y) for(int (I)=(X);(I)<(Y);(I)++) #define REP(I,X,Y) for(int (I)=(Y)-1;(I)>=(X);(I)--) #define ALL(X) (X).begin(),(X).end() #define INF 1000000007 #define LINF 1000000000000000007 typedef long long ll; using namespace std; int main(){ int N,M; cin >> N >> M; vector S(N),T(M); FOR(i,0,N)cin >> S[i]; FOR(i,0,M)cin >> T[i]; sort(ALL(S)); sort(ALL(T)); cout << min(upper_bound(ALL(S),'A')-lower_bound(ALL(S),'A'),upper_bound(ALL(T),'A')-lower_bound(ALL(T),'A')) + min(upper_bound(ALL(S),'B')-lower_bound(ALL(S),'B'),upper_bound(ALL(T),'B')-lower_bound(ALL(T),'B')) << endl; }