sp存储P的个数
sa存储可组合成PA个数
st存储PAT个数
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
int main()
{
string s;
cin >> s;
ll sp=0, sa=0, st=0;
for(int i=0; i<s.length(); i++){
if(s[i] == 'P'){
sp++;
}else if(s[i] == 'A'){
sa += sp;
}else{
st = (st+sa)%MOD;
}
}
cout << st << endl;
return 0;
}