#include #include #include using namespace std; int main() { int N, M; string s, t; cin >> N >> M >> s >> t; int sa = 0, ta = 0; for (int i = 0; i < N; ++i) sa += (s[i] == 'A'); for (int i = 0; i < M; ++i) ta += (t[i] == 'A'); int sb = N - sa, tb = M - sb; cout << min(sa, ta) + min(sb, tb) << '\n'; return 0; }