#include using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { int n, m; string s, t; cin >> n >> m >> s >> t; int a1 = 0, a2 = 0, b1 = 0, b2 = 0; for (char c : s) (c == 'A' ? a1 : a2)++; for (char c : t) (c == 'A' ? b1 : b2)++; cout << min(a1, b1) + min(a2, b2) << endl; return 0; }