Count the substring

3

1 votes
Problem

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

Time Limit: 3
Memory Limit: 256
Source Limit:
Editor Image

?