#include using namespace std; int main() { int N, M; string S, T; cin >> N >> M >> S >> T; int NA = 0; int NB = 0; int MA = 0; int MB = 0; for (auto &s : S){ if (s == 'A'){ ++NA; }else{ ++NB; } } for (auto &t : T){ if (t == 'A'){ ++MA; }else{ ++MB; } } cout << min(NA, MA) + min(NB, MB) << endl; return 0; }