package m.shin; import java.util.Scanner; public class Con559 { public static void main(String[] args) { Scanner s = new Scanner(System.in); String str = s.nextLine(); s.close(); int count = 0 , b = 0; for(int i = 0;i < str.length();i++){ if(str.charAt(i) == 'A'){ count += b; }else{ b++; } } System.out.println(count); } }