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: .