#K14926. Unique String Transformation

    ID: 24243 Type: Default 1000ms 256MiB

Unique String Transformation

Unique String Transformation

You are given a string S consisting of lowercase letters. Your task is to calculate the minimum cost required to transform S into a string that contains only distinct characters. The only allowed operation is the removal of characters, and the cost is simply the number of characters removed.

More formally, let S be a string of length n. We want to obtain a string T such that every character in T is unique. The cost is defined as:

$\text{cost} = n - |\{\text{unique characters in } S\}|$

You need to process multiple test cases. For each test case, compute and print the result on a new line.

Example:

Input:
3
aabb
abc
zzz

Output: 2 0 2

</p>

inputFormat

The first line of input contains a single integer T (the number of test cases). Each of the following T lines contains a single string S composed of lowercase letters.

outputFormat

For each test case, print the minimum cost required to transform the string into one with all distinct characters. Each result should be printed on a new line.

## sample
3
aabb
abc
zzz
2

0 2

</p>