Some terrorist attacks on Indian border. Now Indian Army have to send his soldiers to fight against terrorist. There are total N soldiers in the camp. Every soldier has a skill denoted by a single character lies between A-Z (all skills are in CAPITAL LETTERS). Now commander gave order to stand all the soldiers in a row, so that he can select a segment of maximum number of soldiers from the row to sent them for fighting against the terrorist.

INPUT

First line contains number of test cases T, for each test case a single line represents soldiers standing in a row with their skill.

OUTPUT

A single line representing maximum number of soldiers that commander selects for each test case.

Constraints:

1 ≤ T ≤100

1 ≤ N ≤ 10000

SAMPLE INPUT
2
ABDEFGABEF
GHJKLMNOPQ

SAMPLE OUTPUT
6
10

Explanation

For first test case, the soldier skills are “ABDEFGABEF” maximum soldiers with different skills are “ABDEFG” and “BDEFGA”, "DEFGAB" with length 6.
def unique(s):
    i, j = 0, 0
    I, J = 0, 0
    H = set([])
    while j < len(s):
        if s[j] in H:
            H.remove(s[i])
            i += 1
        else:
            H.add(s[j])
            j += 1
        if J - I < j - i:
            I, J = i, j
    return s[I:J]
def main():
	for i in xrange(input()):
		skills=raw_input()
		print len(unique(skills))
		
if __name__ == '__main__':
	main()