flip-flop-2
Source: hackerearth
Difficulty: UNKNOWN_DIFFICULTY

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


tt = int(input())
while tt:
	s = input()
	i = 0
	l = len(s)
	delete = 0
	while i < l-1:
		pos = i+1
		while pos < l and  s[i] == s[pos]:
		  delete +=1
		  pos+=1
		i = pos
	print(delete)
	tt-=1


t=eval(input())
while(t>0):
	y=input()
	p=list(y)
	l=len(p)
	i=0
	c=0
	while(l>1):
		if(p[i]==p[i+1]):
			c=c+1;
		i=i+1
		l=l-1    
	print(c)
	t=t-1


t = int(input())

while t:
	t-=1
	
	s = input().strip()
	
	c = sum([1 for i in range(1, len(s)) if s[i] == s[i-1]])
	
	print(str(c))


t = int(input())
while t:
	s = input()
	i = 0
	l = len(s)
	delete = 0
	while i < l-1:
		pos = i+1
		while pos < l and  s[i] == s[pos]:
		  delete +=1
		  pos+=1
		i = pos
	print(delete)
	t-=1


for _ in range(eval(input())):
	string = input()
	slen = len(string)
	count = 0
	for index in range(slen -1):
		if string[index] == string[index + 1]:
			count += 1
	print(count)


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
#print 'Hello World!'
T=eval(input())
while(T!=0):
	flip=input()
	deletions=0
	
	for i in range(0,len(flip)-1):
		if flip[i]==flip[i+1]:
			deletions=deletions+1
	print(deletions)
		
	T-=1


import sys
ip=[]
for line in sys.stdin:
	ip.append(line)
for i in range(0,len(ip)):
	ip[i]=ip[i].rstrip('\n')
for i in ip[1:len(ip)]:
	deletion=0
	if i[0]=='X':
		word='Y'
	else:
		word='X'
	for j in range(1,len(i)):
		if i[j]!=word:
			deletion=deletion+1
		elif word=='X':
			word='Y'
		elif word=='Y':
			word='X'
	print(deletion)



n = int(input())
for test in range(n):
	count = 0
	s = str(input())
	for ind in range(1,len(s)):
		if s[ind] == s[ind -1 ]:
			count +=1
		else:
			pass
	print(count)




'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
t = int(input())
for _ in range(t):
	s = input()
	if s[0]=='X':
		ex = 'Y'
	else:
		ex = 'X'
	count =0
	for ch in s[1:]:
		if ch!=ex:
			count+=1
		else:
			if ch=='X':
				ex = 'Y'
			else:
				ex = 'X'
	print(count)