#include <iostream>
#include <cstring>
using namespace std;
const int N = 1e5 + 10,MOD = 1e9 + 7;
char s[N],p[] = " PAT";
int f[N][4];
int main()
{
cin >> s + 1;
int n = strlen(s + 1);
f[0][0] = 1;
for(int i = 1;i <= n;i++)
{
for(int j = 0;j <= 3;j++)
{
f[i][j] = f[i - 1][j];
if(s[i] == p[j]) f[i][j] = (f[i][j] + f[i - 1][j - 1]) % MOD;
}
}
cout << f[n][3] << endl;
return 0;
}