Children's Railway - 2#333

Children's Railway - 2

1 second
64 megabytes
Hard

Vitko's mom forbade him from engaging with an unknown language and took away all his blocks that did not have Latin alphabet letters. So, he found a new hobby with a toy railway. Initially, he built several depots to store extra carriages, but he has not figured out how to retrieve them yet. With a supply of blocks featuring uppercase Latin letters, Vitko decided to secretly study English. Since his mom also banned using any English dictionary, Vitko decided to create his own.

In his dictionary, he first recorded the word formed from the initial arrangement of blocks on the carriages. Then he created new words by removing some letters from the beginning, the end, or both ends of the train, each time starting from the original arrangement of blocks.

How many distinct words can Vitko include in his unusual "English" dictionary?

Input

The first and only line contains the initial arrangement of blocks. The number of blocks does not exceed .

Output

Output the number of distinct words in Vitko's dictionary.

Examples

Example 1

Loading
Loading