Under construction

Still being built. Things may change

New Word

Time limit1sMemory limit1024 MB

Summary
Count the distinct words formed by joining a non-empty prefix of s with a non-empty suffix of t.
Level

Medium6 of 10

Topics
String, Math
Solved
No attempts yet

Statement

In computer science, people sometimes form a new word by taking the beginning of one word and the end of another. For example, the words "tree" and "heap" form the word "treap".

You are given a word ss and a word tt. How many different words can be formed by appending a non-empty suffix of tt to a non-empty prefix of ss?

Input

The first line contains the word ss.

The second line contains the word tt.

Both words are non-empty and consist of lowercase Latin letters. The length of each word does not exceed 100 000100\,000.

Output

Print one integer, the number of different words that can be formed by appending a non-empty suffix of tt to a non-empty prefix of ss.

Examples1

  1. Example 1

    Input
    tree
    heap
    
    Expected output
    14