/* 递推,A前面有多少个P,后面有多少个T,把个数相乘就是以这个A为中心,pat的个数 */ #include<cstdio> #include<cstring> using namespace std; const int N =1e5; const int mod = 1e9+7; int main() { int ans = 0; char str[N+5]; int pnum[N+5] = {0}; scanf("%s",str); int len = strlen(str); for(int i = 0; i<len; ++i) { if(i>0) pnum[i] = pnum[i-1]; if(str[i] == 'P') pnum[i]++; } int tnum = 0; for(int i = len-1; i>=1; i--) { if(str[i]=='A') ans = (ans+pnum[i]*tnum)%mod; else if(str[i]=='T') tnum++; } printf("%d\n",ans); return 0; }