cswork / OAOpen practice workspace

AmazonOA #118

Count Distinct Passwords

Estimated MediumJudge-ready

Topics (AI-labelled)HashingBits & Math

You must reverse one non-empty contiguous substring; count how many distinct strings can be obtained. A reversal of length 1 is allowed and keeps the original string.

Input

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

Output

Output a single integer answer.

Example 1

Input:

abc

Output:

4

Example 2

Input:

aaa

Output:

1

Example 3

Input:

aba

Output:

3

Example notes

Example 1: the original string, bac, acb and cba, 4 in total. Example 2: no reversal changes aaa, so the answer is 1. Example 3: the original string plus baa and aab, 3 in total.

Editorial

Loading solution…