485. Total Distinctness of a String

0

Hard

The Distinctness of a string refers to the count of unique characters present in the string. For instance, the distinctness of the string "abbca" is 3 because it contains 3 distinct characters: 'a', 'b', and 'c'. Given a string s, the task is to calculate the total distinctness of all its substrings. A substring is a contiguous sequence of characters within the string.

Input Format

A single line containing a string s.

Output Format

An integer representing the total distinctness of the string.

Example

Input

abbca

Output

28

Constraints

1 <= N <= 10^5
Loading...

View Submissions

Console