In order to celebrate Women's day, Stella started playing with string S. She needs to know the maximum number of characters between any 2 same characters in the string.
As she is busy in playing, help her for the same.
If there are no 2 same characters in the string, print 1.
Note: String is composed of lowercase letters of the Latin alphabet.
Input:
First line contains one integer T, denoting the number of test cases.
Each of the next T line contains one string S.
Output:
For each test case, output the maximum number of characters between any 2 same characters in the string. If there are no 2 same characters in the string, print 1.
Print answer for each test case in a new line.
Constraints:
1≤T≤10
1≤|S|≤105, where S determines the length of the string.
String is composed of lowercase alphabets ranging from a to z.
Here, for string = aba
There is only one character between 2 occurrences of a.
2) For string = babcddc
There is one character between 2 occurrences of b, and 2 characters between 2 occurrences of c. So the answer is 2.