#K641. Longest Distinct Sequence
Longest Distinct Sequence
Longest Distinct Sequence
You are given a string \( s \). You are allowed to swap any two different characters at most once. Your task is to determine the maximum number of distinct characters in the string that can be obtained by performing such a swap if needed.
Note that swapping may not increase the number of distinct characters if the string already contains all unique characters. Formally, let \( \text{distinct}(s) \) be the number of distinct characters in \( s \). You need to output \( \text{distinct}(s) \).
inputFormat
The first line contains an integer \( T \) representing the number of test cases. Each of the next \( T \) lines contains a string \( s \) representing one test case.
outputFormat
For each test case, output a single integer on a new line — the maximum number of distinct characters in \( s \) after performing at most one swap.
## sample3
abc
aaaa
abacaba
3
1
3
</p>