flip-flop-6
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


for _ in range(eval(input())):
	ins = input().strip()
	print(sum([a==b for a, b in zip(ins, ins[1:])]))


t = int(input())
while t>0:
	t-=1
	str = input()
	cnt=1
	i=1
	while i<str.__len__():
		if str[i]==str[i-1]:
			cnt+=1
		i+=1
	print(cnt-1)



test = int(input())
while(test):
	string = input()
	counter = 0
	for i in range(1,len(string)):
		if string[i] == string[i-1]:
			counter += 1
	print(counter)

	test -= 1



t=int(input())
for e in range(t):
	f=input()
	s,i=0,0
	if len(f)==1:
		print(0)
		continue
	c=f[0]
	for i in f:
		if c==i: s+=1
		else: c=i
	print((s-1))


n = int(input()) 
l=[]
for i in range(n):
	l.append(input())
nn = 0

for j in l:
	s = str(j)
	nn = len(s)
	c = 0
	for i in range(nn-1):
		if(s[i] == s[i+1]):
			c=c+1
	print(c)


t=int(input())
for ti in range(t):
	c=0
	s=input()
	for i in range(0,len(s)-1):
		if s[i]==s[i+1]:
			c=c+1
	print(c)


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


global de
de=0

def out(s):
	n=len(s)
	s=list(s)
	l=n
	i=0
	while(i<l-1):
		if s[i]==s[i+1]:
			del s[i+1]
			global de
			de+=1
			l -= 1
			continue
		else:
			i+=1
	print(n-len(s))


t=eval(input())
for i in range (t):
	s=input()
	out(s)
	global de
	de=0



global de
de=0

def out(s):
	n=len(s)
	s=list(s)
	l=n
	i=0
	while(i<l-1):
		if s[i]==s[i+1]:
			del s[i+1]
			global de
			de+=1
			l -= 1
			continue
		else:
			i+=1
	print(n-len(s))


t=eval(input())
for i in range (t):
	s=input()
	out(s)
	global de
	de=0



t=int(input())
while t>0:
	st_x='X'
	err_x=0
	
	st_y='Y'
	err_y=0
	for x in input():
		if x==st_x:
			if st_x=='Y':
				st_x='X'
			else:
				st_x='Y'
		else:
			err_x+=1
		
		if x==st_y:
			if st_y=='X':
				st_y='Y'
			else:
				st_y='X'
		else:
			err_y+=1
	print(min(err_x,err_y))
	t-=1


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

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
cases = eval(input())
for case in range(cases):
	S = input()
	deletion = 0
	length = len(S)
	A = ''
	for char in S:
		if char == 'X':
			A += '0'
		else:
			A += '1'
	for count in range(length -1):
		if int(A[count]) ^ int(A[count + 1]) == 0:
			deletion += 1
	print(deletion)