import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int N = scan.nextInt(); int M = scan.nextInt(); String S = scan.next(); String T = scan.next(); scan.close(); int a1 = 0; int b1 = 0; int a2 = 0; int b2 = 0; for(int i = 0; i < N; i++) { char c = S.charAt(i); if(c == 'A') { a1 ++; }else { b1 ++; } } for(int i = 0; i < M; i++) { char c = T.charAt(i); if(c == 'A') { a2 ++; }else { b2 ++; } } int ans = Math.min(a1, a2) + Math.min(b1, b2); System.out.println(ans); } }