Problem: Xenny was a teacher and his class consisted of N boys and N girls. He took all his students to the playground and asked them to stand in a straight line. The boys and the girls formed a perfect line, but Xenny seemed unhappy. He wanted them to form an alternating sequence of boys and girls, i.e., he wanted that after a boy, there should be a girl in the line, and vice-versa.

In order to form an alternating sequence, a boy and a girl could swap their positions.

Given the original sequence in which the boys and girls were standing, find the minimum number of swaps required to form an alternating sequence.

Note: An alternating sequence can start either with a boy or a girl.

Input
First line of input consists of a natural number T - the number of testcases.
T testcases follow. For each testcase:

First line consists of a single integer N - the number of boys, and the number of girls.
Second line consists of a string of length 2N, representing the original sequence.
In this string, a boy is represented by uppercase character B and a girl by G.

Output
For each testcase, print the minimum number of swaps required to get an alternating sequence on a new line.

Constraints
1 ≤ T ≤ 5

1 ≤ N ≤ 10^6

SAMPLE INPUT
1
2
BBGG

SAMPLE OUTPUT
1

Explanation

The first boy from left  can swap his position with the first girl from right to get the sequence:

GBGB

This is an alternating sequence and it was obtained using 1 swap.

Solution (in PYTHON):

Solution:
'''
# 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=input()
while(t):
	n=input()
	s=raw_input()
	l=len(s)
	lst1=list()
	lst2=list()
	ans=0
	c1=0
	c2=0
	for x in xrange(0,l,2):
		if(s[x]==s[x+1]):
			lst1.append(s[x])
			lst1.append(s[x+1])
		else:
			lst2.append(s[x])
			lst2.append(s[x+1])
	#print lst1,' ',lst2
	if lst1:
		ans=lst1.count('B')
	if lst2:
		l2=len(lst2)
		for x in xrange(0,l2,2):
			if(lst2[x]=='B' and lst2[x+1]=='G'):
				c1=c1+1
			elif(lst2[x]=='G' and lst2[x+1]=='B'):
				c2=c2+1
#print c1,' ',c2
	if(c1>c2):
		ans = (ans/2) + c2
	else:
		ans = (ans/2) + c1
	print ans
	t=t-1