#C5584. Minimum Operations to Make Characters Unique

    ID: 49249 Type: Default 1000ms 256MiB

Minimum Operations to Make Characters Unique

Minimum Operations to Make Characters Unique

Given a string S consisting of characters, compute the minimum number of operations required to make all characters in S unique. In one operation, you can remove any duplicate occurrence of a character, leaving only its first occurrence. In other words, for each character that appears more than once, you must remove the extra occurrences so that every character appears exactly once.

Formally, if a character appears f times, you need to perform f - 1 operations for that character. The answer is the sum over all characters of (f - 1) for every character where f > 1.

You should read the input from standard input (stdin) and print the output to standard output (stdout).

inputFormat

A single line containing the string S. The string may contain any printable characters. An empty string is allowed.

outputFormat

An integer representing the minimum number of operations required to make all characters in S unique.## sample

abca
1