#P9576. 「TAOI-2」Ciallo~(∠・ω< )⌒★
「TAOI-2」Ciallo~(∠・ω< )⌒★
Background
Yuzu fans, that is enough.
~(·<)~(·<)~(·<)~(·<)~(·<)~(·<)~(·<)~(·<)~(·<)~(·<)~(·<)~(·<)~(·<)~(·<)

Problem Description
Little likes to make up words. He learned a way to make up words.
First, he has a "template string", denoted as . Then he chooses a pair , deletes the -th to -th characters of , and concatenates the remaining parts. He denotes the new string obtained as .
Next, he chooses a new pair , and lets be the string formed by the -th to -th characters of . The word he makes is .
For example, if the "template string" is , then one way is to choose , , obtaining , then choose , , obtaining .
Now little has a "target string" . He wants to know how many different plans can use the "template string" to produce the word . Two plans are defined to be the same if and only if the chosen are all the same.
Input Format
There are two lines, which are the strings and , respectively.
Output Format
There is one line, representing the number of plans to produce the "target string" .
aabbaaba
aba
23
ciaohallo
ciallo
2
babacbbaababbacbababbabbbaaabaabababbabbabababba
ababab
1535
sssssssssssssssssssssssssssssssssssss
sss
15470
abcbbbcbcbcbacbacbaaabcbcbcbaabacbca
cb
3995
Hint
Constraints
This problem uses bundled testdata.
- Subtask 0 (6 points): , .
- Subtask 1 (10 points): , .
- Subtask 2 (10 points): .
- Subtask 3 (10 points): .
- Subtask 4 (20 points): , .
- Subtask 5 (14 points): .
- Subtask 6 (30 points): No special constraints.
For all testdata, , . contain only lowercase English letters.
Translated by ChatGPT 5