#R1020. [KBC002D] String
[KBC002D] String
Problem Statement
Given two strings, and , both of length , which are composed of uppercase letters, and a string of length .
A position is considered valid if the substring formed by selecting uppercase letters from and is equal to .
Output the count of valid positions modulo .
We consider two strings to be different if there exists a position such that .
Constraints
- and .
- The solution is guaranteed to exist.
Input
- The first line contains two positive integers and .
- The next two lines contain strings and .
- The last line contains characters representing .
Output
The count of valid positions modulo .
Sample Input 1
4 4
LOVE
EVOL
LOVE
Sample Output 1
4
- Possibility 1: ;
- Possibility 2: ;
- Possibility 3: ;
- Possibility 4: .
Sample Input 2
1 3
Y
Y
YYY
Sample Output 2
2
- Possibility 1: ;
- Possibility 2: .