import java.util.Arrays; import java.util.LinkedList; import java.util.Scanner; public class Main { public static long MOD = 1000000007; public static void main(String[] args) { Scanner sc = new Scanner(System.in); // めんどうなので A だけ寄せる final char[] ins = sc.next().toCharArray(); int answer =0 ; int curr_A_index = 0; for(int index = 0; index < ins.length; index++){ if(ins[index] != 'A'){ continue; } answer += (index - curr_A_index); curr_A_index++; } System.out.println(answer); } }