#K69077. Minimal Characters Removal

    ID: 33006 Type: Default 1000ms 256MiB

Minimal Characters Removal

Minimal Characters Removal

You are given a string s consisting of lowercase and/or uppercase characters. Your task is to determine the minimum number of characters that need to be removed so that all remaining characters in the string are unique.

The answer can be computed by removing duplicate occurrences. Mathematically, this can be expressed as:

$$ answer = |s| - |\{ c \mid c \in s \}| $$

For example, if s = "abacaba", then the answer is 4 because after removing 4 characters, all remaining characters are distinct.

inputFormat

The input consists of a single line containing the string s.

Note: The string may contain only alphabetical characters. The length of s can be large (up to 200,000 characters).

outputFormat

Output a single integer representing the minimal number of characters that need to be removed so that all characters in the string are unique.

## sample
abacaba
4

</p>