eolymp
bolt
Try our new interface for solving problems
Problems

Biwordism

Biwordism

Everyone knows that fashion is a capricious lady. Until recently, modernism was popular in literature, and now biwordism is on a roll. The authors choose two words w1 and w2, and compose the text from phrases starting with w1 and ending with w2. But plagiarism lovers have appeared, who take someone else's text, extract all suitable phrases from it and seem to compose their own works. Your task is to calculate how many corresponding phrases can be obtained from the given text. In the example below, the word w1 = "no", w2 = "yes", and text: «wedecidednobullyingnowarpeaceyesnoboredomjoyyes» contains the word w1 three times, starting at positions 10, 20 and 33, and twice the word w2, which ends at positions 32 and 47. (The numbering of letters in the line starts with 1). Therefore, this text contains 5 fragments that are suitable for a piece in the style of "biwordism": [10; 32], [20; 47], [33, 47], [10, 47] and [20; 32].

Input

The program enters from the first two lines the words w1 and w2, and from the third line text. All lines use only lowercase letters without punctuation or spaces. The length of each line is between 2 and 100,000. The words w1 and w2 are made up of different letters.

Output

Count the number of different pieces of text that start with w1 and end with w2.

Time limit 0.1 seconds
Memory limit 64 MiB
Input example #1
no
yes
wedecidednobullyingnowarpeaceyesnoboredomjoyyes
Output example #1
5
Source Dnipro Open School Olympiad in Informatics 2020