count-the-substring-3

Given a string S made of letters x, y and z, find the number of sub strings that do not contain all the letters x, y and z. That is the number of sub strings that do not contain at least one of the letters x or y or z. Note that the Sub string should contain minimum one letter(x or y or z).

Input Format  : 
First line of the input is the number of test cases T. It is followed by T lines. Each test case consist a single line which is the string S.

Output Format:
For each test case , print the correct answer.

Constraints 
1 ≤ length of (S) ≤ 10^6

SAMPLE INPUT
2
xyzxy
xyz

SAMPLE OUTPUT
9
5

Source: hackerearth | Difficulty: UNKNOWN_DIFFICULTY


Solutions: