#yuki_559 s=raw_input() l=[] for i in xrange(len(s)): if s[i]=='A': l.append(i) cnt=0 for i in xrange(len(l)): cnt+=l[i]-i print cnt