#K67257. Min Operations to Empty String

    ID: 32602 Type: Default 1000ms 256MiB

Min Operations to Empty String

Min Operations to Empty String

You are given a string S consisting of lowercase English letters. In one operation, you can choose any character and remove all of its occurrences from the string. The goal is to determine the minimum number of operations required to make the string empty.

For example, consider the string S = "aabb". One optimal sequence of operations is:

  • Remove all occurrences of 'a' to get "bb".
  • Remove all occurrences of 'b' to get an empty string.

Thus, the minimum number of operations is 2. In general, this value is equal to the number of distinct characters in S (with the convention that an empty string requires 0 operations).

Note: All formulas are presented in LaTeX format when applicable. For example, the answer for a non-empty string S is given by \(\text{Answer} = |\{ c : c \text{ appears in } S \}|\).

inputFormat

The first line of input contains an integer T representing the number of test cases. Each of the following T lines contains a string S (which may be empty) composed of lowercase English letters.

outputFormat

For each test case, output a single integer on a new line that represents the minimum number of operations required to empty the string.

## sample
3

aabb
abcd
abcabcd
2

4 4

</p>