class Program { static void Main(string[] args) { int[] clothes = Array.ConvertAll(Console.ReadLine().Split(' '), num => int.Parse(num)); string s = Console.ReadLine(); int[] topCount = { 0, 0 }; topCount = ClothesCount(s, topCount); string t = Console.ReadLine(); int[] bottomCount = { 0, 0 }; bottomCount = ClothesCount(t, bottomCount); int days = JudgeClothes(topCount,bottomCount); Console.WriteLine(days); } private static int JudgeClothes(int[] topCount, int[] bottomCount) { int days = 0; for( int i = 0; i < 2; i++) { if (topCount[i] < bottomCount[i]) { days += topCount[i]; } else { days += bottomCount[i]; } } return days; } private static int[] ClothesCount(string clothers, int[] countList) { for(int i = 0; i < clothers.Length; i++) { if (clothers[i] == 'A') { countList[0]++; } else { countList[1]++; } } return countList; } }