using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace YukiCoder { public class SwapAB { public static void Main() { int SwapCount = 0; List SwapString = Console.ReadLine().ToCharArray().ToList(); int doCount = SwapString.Count; while (--doCount != 0) { for (int i = 0; i < SwapString.Count - 1; i++) { if (SwapString[i] == 'B' && SwapString[i + 1] == 'A') { SwapString[i] = 'A'; SwapString[i + 1] = 'B'; SwapCount++; continue; } } } Console.WriteLine(SwapCount); } } }