using System; using System.Linq; class No559 { static void Main() { var str = Console.ReadLine(); var letterCount = str.Count(x => x == 'A'); var place = 0; for (int i = 0; i < letterCount; ++i) place += i; var letterIndexCount = str.Where(x => x == 'A').Select((x, index) => index).Sum(); Console.WriteLine(letterIndexCount - letterCount); } }