t = raw_input()

```
t = int(t)
a = []
for i in range(26):
a.append([0,0])
for i in range(t):
cnt = 0
max_cnt = 0
start = 0
for i in range(26):
a[i] = [0,0]
s = raw_input()
for j in range(len(s)):
index = ord(s[j]) - 97
if(a[index][0] == 1):
pre_index = a[index][1]
for k in range(start,pre_index+1):
del_index = ord(s[k]) - 97
a[del_index][0] = 0
cnt = cnt - 1
a[index][0] = 1
a[index][1] = j
start = pre_index+1
cnt = cnt + 1
else:
a[index] = [1,j]
cnt = cnt + 1
if max_cnt < cnt:
max_cnt = cnt
print max_cnt
```