Deepak like strings which are in flip flop in nature. For example, he likes XYXYX, while he doesn't like XXYX. Now he want to convert every string into a string which he likes. for this, he only delete the character in the string.

Now find the minimum number of delete operation which is required to covert a string that deepak likes.

Input Format : 

The first line contains an integer N i.e the number of test cases.
Next N lines contain a string each.

Output Format : 

For each test case, print the minimum delete operation required.

Constraints :

1 ≤ N ≤ 10
1 ≤ length of String ≤ 10^5

SAMPLE INPUT
5
XXXX
YYYYY
XYXYXYXY
YXYXYX
XXXYYY

SAMPLE OUTPUT
3
4
0
0
4

Explanation

XXXX => X, 3 deletions
YYYYY => Y, 4 deletions
XYXYXYXY => XYXYXYXY, 0 deletions
YXYXYXYX => YXYXYXYX, 0 deletions
XXXYYY => XY, 4 deletions

Difficulty: UNKNOWN_DIFFICULTY

Solutions:
def del_adj(list1):
	list2 = []
	ln_1 = len(list1)
	for i in range(1,ln_1):
		e = list1[i-1]
		if list1[i] != e:
			list2.append(list1[i])
	ln_2 = len(list2)

	print((ln_1 - ln_2 - 1))

tc = int(eval(input()))
while tc :
	string = input()
	list1 = list(string)
	del_adj(list1)
	tc -= 1


a=eval(input())
for i in range(a):
	b=input()
	count = 0
	for i in range(len(b)-1):
		if b[i]=='X':
			if b[i+1]=='X':
				count +=1
		else:
			if b[i+1]=='Y':
				count +=1
	print(count)
		


for _ in range(eval(input())):
	s = list(input())
	x, y = 0, 0
	for i in range(len(s)):
		if s[i] == "X":
			x+=1
		elif s[i] == "Y":
			y += 1
	if x == len(s) or y == len(s):
		print(len(s)-1)
	else:
		cnt = 0
		for i in range(len(s)-1):
			if s[i] == s[i+1]:
				cnt+=1
		print(cnt)        
		 


N = eval(input(""))
def ff(string):
	output = 0
	string = string[:].lower()
	if ((string == 'x')or(string == 'y')):
		output = 0
	else:
		flag = 1
		for i in range(len(string)-1):
			if ( string[i] == string[i+1]):
				output = output + 1
	return output

for i in range(N):
	st = input("")
	print(ff(st))


t=int(eval(input()))
while(t):
	c=0
	a=input()
	l=len(a)
	for i in range(0,l-1,1):
		if(a[i]==a[i+1]):
			c+=1
	print(c)
	t=t-1
			


a=int(input())
outt=[]
for x in range(a):
	b=input()
	c=0
	l=[]

	for i in range(len(b)):

		if i+1!=len(b):

			if b[i]==b[i+1]:

				c+=1
	outt.append(c)
for k in outt:
	print (k)


t = input()
t = int(t)
for i in range(1,t+1):
	str_to_flip = input()
	list_to_flip = list(str_to_flip)
	
	no_of_del = 0
	for j in range(1,len(list_to_flip)):
		
		prev = list_to_flip[(j - 1)]
		
		curr = list_to_flip[j]
		
#		next_one = list_to_flip[(idx + 1) % len(list_to_flip)]
		if prev != curr:
			continue
		else:
			no_of_del = no_of_del + 1
			
	print(no_of_del)	


cases = int(input())

for case in range(cases):
	s = input()
	n = len(s)
	ans = 0
	
	for i in range(n-1):
		if s[i] == s[i+1]:
			ans += 1
	
	print(ans)