#include #include #include using namespace std; int main() { int n, m; cin >> n >> m; string s, t; cin >> s; cin >> t; int cnta[2] = {}, cntb[2] = {}; for (int i = 0; i < n; ++i) { if (s[i] == 'A') cnta[0]++; if (s[i] == 'B') cntb[0]++; } for (int i = 0; i < m; ++i) { if (t[i] == 'A') cnta[1]++; if (t[i] == 'B') cntb[1]++; } cout << min(cnta[0], cnta[1]) + min(cntb[0], cntb[1]) << endl; return 0; }