import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import static java.lang.System.in; public class No559 { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(in)); int numOfB = 0; String S = reader.readLine(); int counter = 0; for (int i = 0; i < S.length(); i++) { if (S.charAt(i) == 'A') { counter += numOfB; } else { numOfB += 1; } } System.out.println(counter); } }