#include<stdio.h>
#include<string.h>
#define N 100005
int main()
{
long long count=0;
int i=0,k=0,p=0,t=0,b[N],a[N],n;
char s[N],ch;
while((ch=getchar())!='\n')
{
if(ch=='P')p++;
if(ch=='A')a[k++]=p;
s[i++]=ch;
}
s[i]='\0';
n=k;
for(i=strlen(s)-1;i>=0;i--)
{
if(s[i]=='T')t++;
if(s[i]=='A')b[--k]=t;
}
for(i=0;i<n;i++)
{
count+=a[i]*b[i];
count%=1000000007;
}
printf("%lld",count);
}
转载于:https://www.cnblogs.com/xLester/p/7570431.html