#include using namespace std; using ll=long long; #define rep2(i, a, n) for(int i = (a); i < (n); i++) #define rep(i, n) rep2(i,0,n) int main(){ cin.tie(nullptr);ios_base::sync_with_stdio(false); int n,m;cin>>n>>m; string s,t; cin>>s>>t; int a=0,b=0,c=0,d=0; for(char hoge:s)hoge=='A'?a++:b++; for(char hoge:t)hoge=='A'?c++:d++; int ans=0; ans+=min(a,b); ans+=min(c,d); cout<