void main(){ import std.stdio, std.string, std.conv, std.algorithm; import std.range; string s; rd(s); int m=0; foreach(i, c; s){ if(c=='A') continue; foreach(j; i..s.length)if(s[j]=='A') m++; } writeln(m); } void rd(T...)(ref T x){ import std.stdio, std.string, std.conv; auto l=readln.split; foreach(i, ref e; x){ e=l[i].to!(typeof(e)); } }