#include using namespace std; int main() { int i; int iPos; int iSum; char S[ 20 ]; char C; cin >> S; iPos = 0; iSum = 0; i = 0; while( ( C = S[ i ] ) != '\0' ) { if( C == 'A' ) { iSum += i - iPos; iPos++; } i++; } cout << iSum << endl; return 0; }