#include using namespace std; using ll = long long; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b A){ ll L = A.size(); FOR(i, 0, L){ if(i) cout << ' '; cout << A[i]; } cout << endl; } int main(){ cin.tie(0); ios::sync_with_stdio(false); // input ll N, M; cin >> N >> M; string s; cin >> s; string t; cin >> t; map mp0; map mp1; for(char c : s){ mp0[c]++; } for(char c : t){ mp1[c]++; } ll ans = min(mp0['A'], mp1['A']) + min(mp0['B'], mp1['B']); p(ans); return 0; }