Children's Railway - 2
Vitko's mom forbade him from engaging with an unknown language and took away all his blocks that didn't contain letters of the Latin alphabet. So, he found a new hobby with a toy railway. Initially, he built several depots to store extra carriages, but he hasn't figured out how to retrieve them yet. With a supply of blocks featuring capital Latin letters, Vitko decided to secretly study English. Since his mom also banned the use of an English dictionary, Vitko decided to create his own.
In his dictionary, he first recorded the word formed from the initial sequence of blocks on the carriages. Then, he created new words by sending some letters to the depot from the beginning, the end, or both sides of the train, always starting with the original sequence of blocks.
How many distinct words can Vitko include in his unique "English" dictionary?
Input
The first and only line contains the initial sequence of blocks. The number of blocks does not exceed 5000.
Output
Output the number of distinct words in Vitko's dictionary.