cswork / OAOpen practice workspace

AmazonOA #180

Find Number of Possible Unique Strings

Estimated MediumJudge-ready

Topics (AI-labelled)HashingBits & Math

Choose any non-empty contiguous substring and reverse it once. Find how many distinct strings can be obtained. Reversing a substring of length 1 is allowed, so the original string is included.

Input

One line containing a lowercase string of length 1..100000.

Output

Output a single integer, the answer.

Example 1

Input:

abc

Output:

4

Example 2

Input:

aaa

Output:

1

Example 3

Input:

aba

Output:

3

Example notes

The answers are 4, 1 and 3.

Editorial

Loading solution…