Prefix and Suffix

Count the distinct substrings of S that both start with string A and end with string B, where A and B may overlap within a substring.

Medium6StringHash mapString matchingNo attempts yetTime limit2sMemory limit512 MB

Problem

You are given three strings SS, AA, and BB.

Write a program that counts how many distinct substrings of SS start with AA and end with BB. A substring is a contiguous block of SS, and two substrings made of the same characters count as one even when they appear at different positions. Inside one substring, the block taken by AA and the block taken by BB may overlap.

Input

The first line contains SS, the second line contains AA, and the third line contains BB. All three strings consist of lowercase letters only, and each length is between 1 and 2,000.

Output

Print the number of distinct substrings of SS that start with AA and end with BB.

Hint

If SS is abababab, AA is a, and BB is b, the substrings that satisfy the condition are ab, abab, ababab, and abababab, so there are four of them.