Ahmed Gafer failed to pass the test, but he got the job because of his friendship with Said and Shahhoud. After working in the kitchen for a while, he blew it. The customers didn't like the food anymore and one day he even burned the kitchen. Now the master Chef is very upset.
Ahmed isn't useful anymore at being a co-Chef, so S&S decided to give him a last chance. They decided to give Ahmed a new job, and make him work as the cashier of the restaurant. Nevertheless, in order not to repeat their previous mistake, they decided to give him a little test to check if his counting skills are good enough for the job. The problem is as follows: 
Given a string A of lowercase English letters, Ahmad was asked to find the number of good substrings.
A substring A[L, R] is good if:

-  The length of the substring is exactly 2 and AL = AR, OR
- The length of the substring is greater than 2,AL = AR and the substring A[L + 1, R - 1] has only one distinct letter.

Anyways, Ahmed struggled trying to find a solution for the problem. Since his mathematical skills are very poor as it turned out, he decided to cheat and contacted you asking for your help. Can you help him in this challenge?

-----Input-----
The first line of the input contains the integer T, indicating the number of test cases.
Each of the following T lines, contains a string A.

-----Output-----
For each test case, output a single line containing a single number, indicating the number of good substrings.

-----Constraints-----

- 1 ≤ T ≤ 100 
- 1 ≤  |A|  ≤ 105 
-  It's guaranteed that the sum of  |A|  over all test cases doesn't exceed 5x105. 

-----Example-----
Input:
2
a
abba

Output:
0
2


-----Explanation-----
Example case 2. The good substrings of abba are: { bb } and { abba }.

Starter code:

Solutions:
# cook your dish here
for _ in range(int(input())):
 s=input()
 count=0
 i=0
 while i<len(s)-1:
  ch=s[i]
  j=i+1 
  while j<len(s) and s[j]==ch:
   j+=1 
  l=j-i
  if i!=0 and j!=len(s) and s[i-1]==s[j] :
   count+=1
  count+=l*(l-1)//2
  #print(s[i:j],count)
  i=j
 print(count) 


# cook your dish here
for _ in range(int(input())):
 s=input()
 count=0
 i=0
 while i<len(s)-1:
  ch=s[i]
  j=i+1 
  while j<len(s) and s[j]==ch:
   j+=1 
  l=j-i
  if i!=0 and j!=len(s) and s[i-1]==s[j] :
   count+=1
  count+=l*(l-1)//2
  #print(s[i:j],count)
  i=j
 print(count) 

for _ in range(int(input())):
 a = input()
 if len(a) == 1:
  print(0)
  continue
 comp = 0
 cont = 1
 ans = 0
 for i in range(1,len(a)):
  if a[i] == a[comp]:
   cont += 1
   if i == len(a) - 1:
    ans += (cont*(cont-1))//2
  else:
   ans += (cont*(cont-1))//2
   if comp != 0 and a[comp-1] == a[i]:
    ans += 1
   comp = i
   cont = 1
 print(ans)

e=10**9+7
t=int(input())
for _ in range(t):
 s=input()
 ans=0
 n=len(s)
 i=1
 m=1
 while i<n and s[i]==s[i-1]:
  m+=1
  i+=1
 ans+=(m*(m-1))//2
 while i<n:
  x=s[i-1]
  i+=1
  m=1
  while i<n and s[i]==s[i-1]:
   m+=1
   i+=1
  ans+=(m*(m-1))//2
  if i!=n and s[i]==x:
   ans+=1
 print(ans)