You are given \(3\) strings \(A, B \) and \(S.\)
You have to count the number of substrings of \(S\) which contains both \(A\) and \(B\) as substring.
Note : A substring is a contiguous sequence of characters within a string. For example, the substrings of the string "abc" are "a", "b", "c", "ab", "bc" and "abc".
Input Format:
The first line contains the string \(A (1 \leq |A| \leq 100,000).\)
The second line contains the string \(B ( 1 \leq |B| \leq 100,000).\)
The third line contains the string \(S ( 1 \leq |S| \leq 200,000).\)
The strings will contain English lowercase letters only.
Output Format:
Print the answer in a single line.
ab c cabc
3
"cabc" has 3 substrings which contain both "ab" and "c" as substring , which are "cab" , "cabc" and "abc".
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor