#P2022B. Subsequence
Subsequence
Subsequence
Time limit: 1 seconds
Memory limit: 512 megabytes
Problem Statement
We define the "JIE number" of a string is the number of triples that satisfy all the following conditions:
1.( is the length of ).
2..
Frank is given a string that contains only 3 characters: . However, due to hacker's attack, some characters of are replaced with .If is the number of the occurrences of in , we can make strings by replacing each occurrence of '?' in S with ,,.
Frank is now wonder the sum of JIE numbers of all the strings. This is easy for him so he ask you to solve it.
Since the answer may be very large, you only need to tell him the result modulo .
Input
The input contains only one string . It is guaranteed that each character in is 'J','I','E' or '?'.
Output
Print a single integer, denoting the answer to the question modulo .
J??E
8
Notes
The strings are: , and their contribution to the answer are: .