import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { new Main().run(); } void run() { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); String str1 = sc.next(); String str2 = sc.next(); int[] cnt1 = new int[2]; int[] cnt2 = new int[2]; for (char c : str1.toCharArray()) { if (c == 'A') ++cnt1[0]; else ++cnt1[1]; } for (char c : str2.toCharArray()) { if (c == 'A') { ++cnt2[0]; } else { ++cnt2[1]; } } int a = Math.min(cnt1[0], cnt2[0]); int b = Math.min(cnt1[1], cnt2[1]); System.out.println(a + b); } void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }