import java.util.ArrayList; import java.util.List; import java.util.Scanner; class Main { public static void main(String[] args) { new Main().compute(); } void compute() { Scanner sc = new Scanner(System.in); String S = sc.next(); List SList = new ArrayList<>(); for (int i = 0; i < S.length(); i++) { SList.add(S.charAt(i)); } int ans = 0; while (SList.contains('A')) { ans += SList.indexOf('A'); SList.remove(new Character('A')); } System.out.println(ans); } }