import java.util.*; public class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); String str = sc.next(); char[] arr =str.toCharArray(); int p = 0; int pa = 0; int pat = 0; for (int i = 0; i < arr.length; i++) { if (arr[i] == 'P'){ p++; }else if (arr[i] == 'A'){ pa += p; pa %= 1000000007; }else{ pat += pa; pat %= 1000000007; } } System.out.println(pat); } }