Toby has found a game to entertain himself.The game is like this:

You are in a coordinate system initially at (0,0) and you are given a sequence of steps which lead to your destination.The steps are given in the form of directions: ’U’ ,’D’ , ’L’ and ‘R’ for up, down, left and right respectively.If you are at position (x,y) then:
- U:move to (x,y+1)
- D:move to (x,y-1)
- L:move to (x-1,y)
- R:move to (x+1,y)
The sequence is provided as a string ‘s’ of characters where $s_i$ $(1 \leq i \leq N)$ is one of the direction character as mentioned above.An example of a sequence of steps is:   UULRUDR

The destination according to this string is (1,2).

You want to remove maximum number of characters from the string such that the resulting string leads to the same destination as before.
For example in the example above we can remove characters at positions 1,3,4,6 and the resulting path will be UUR which will lead to the same destination i.e (1,2).so we reduced the number of steps by 4,and this is our score.
You need to get maximum score.

-----Input:-----
- First line will contain $T$, number of testcases. Then the testcases follow. 
- First line of each testcase contains a single integer $N$,size of string. 
- Second line of testcase contains a string $s$ of size $N$.

-----Output:-----
For each testcase, output a single line containing the maximum score possible.

-----Constraints-----
- $1 \leq T \leq 1000$
- $1 \leq N \leq 10^5$

-----Sample Input:-----
3

7

ULUDLLU

4

RUUR

4

LRLR   

-----Sample Output:-----
2

0

4    

-----EXPLANATION:-----
- 
test case 1:
The final destination after moving according to the sequence is (-3,2).

One way is to remove characters at positions 3,4 and the resulting string will be ULLLU and destination still remains (-3,2).
- 
test case 2: No character can be removed in this case.

Source: codechef | Difficulty: UNKNOWN_DIFFICULTY


Solutions:
from collections import Counter
try:
	for _ in range(int(input())):
		n = int(input())
		s = input()
		d1 = dict(Counter(s))
		(u, d, r, l) = (0, 0, 0, 0)
		if 'U' in d1:
			u = d1['U']
		else:
			u = 0
		if 'D' in d1:
			d = d1['D']
		else:
			d = 0
		if 'R' in d1:
			r = d1['R']
		else:
			r = 0
		if 'L' in d1:
			l = d1['L']
		else:
			l = 0
		x = 0
		y = 0
		if l == r:
			x = 0
		elif l > r:
			x = -(l - r)
		elif r > l:
			x = r - l
		if u == d:
			y = 0
		elif d > u:
			y = -(d - u)
		elif u > d:
			y = u - d
		if x == 0 and y == 0:
			print(n)
			continue
		print(n - (abs(x) + abs(y)))
except:
	pass


for _ in range(int(input())):
	n = int(input())
	s = input()
	x = 0
	y = 0
	rm = 0
	x += s.count('R') - s.count('L')
	y += s.count('U') - s.count('D')
	if y <= 0:
		rm += s.count('U') + s.count('D') + y
	else:
		rm += s.count('U') + s.count('D') - y
	if x <= 0:
		rm += s.count('L') + s.count('R') + x
	else:
		rm += s.count('L') + s.count('R') - x
	print(rm)


for t in range(int(input())):
	n = int(input())
	s = str(input())
	l = abs(s.count('U') - s.count('D')) + abs(s.count('R') - s.count('L'))
	print(n - l)


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	s = input()
	counter = Counter(s)
	print(2 * (max(counter['U'], counter['D']) - abs(counter['U'] - counter['D']) + max(counter['R'], counter['L']) - abs(counter['R'] - counter['L'])))


for _ in range(int(input())):
	n = int(input())
	s = list(str(input()))
	c1 = abs(s.count('U') - s.count('D')) + abs(s.count('R') - s.count('L'))
	print(n - c1)


for u in range(int(input())):
	n = int(input())
	s = input()
	r = min(s.count('U'), s.count('D')) * 2 + min(s.count('L'), s.count('R')) * 2
	print(r)


from collections import Counter
x = int(input())
for i in range(0, x):
	len = int(input())
	string = str(input())
	dict = Counter(string)
	(Ucount, Dcount, Lcount, Rcount) = (dict['U'], dict['D'], dict['L'], dict['R'])
	ans = 0
	if Ucount > 0:
		if Dcount > 0:
			y = abs(Ucount - Dcount)
			ans += Ucount + Dcount - y
	if Lcount > 0:
		if Rcount > 0:
			y = abs(Rcount - Lcount)
			ans += Rcount + Lcount - y
	print(ans)


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	s = list(input())
	print(n - (abs(s.count('L') - s.count('R')) + abs(s.count('U') - s.count('D'))))


for _ in range(int(input())):
	n = int(input())
	s = input()
	uc = s.count('U')
	dc = s.count('D')
	lc = s.count('L')
	rc = s.count('R')
	ans = ''
	if uc > dc:
		ans += 'U' * (uc - dc)
	elif uc < dc:
		ans += 'D' * (dc - uc)
	if lc > rc:
		ans += 'L' * (lc - rc)
	elif lc < rc:
		ans += 'R' * (rc - lc)
	print(n - len(ans))


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	c = abs(s.count('L') - s.count('R')) + abs(s.count('U') - s.count('D'))
	print(n - c)


for t in range(int(input())):
	n = int(input())
	l = list(input())
	total = min(l.count('U'), l.count('D')) + min(l.count('L'), l.count('R'))
	print(2 * total)


from collections import Counter
for i in range(int(input())):
	n = int(input())
	s = input()
	res = Counter(s)
	re = abs(res['D'] - res['U']) + abs(res['L'] - res['R'])
	print(n - re)


from collections import Counter
t = 0
try:
	t = int(input())
except:
	pass
for _ in range(t):
	n = int(input())
	s = input()
	s = s[:n]
	c = Counter(s)
	sums = 0
	sums += min(c['D'], c['U'])
	sums += min(c['L'], c['R'])
	print(sums * 2)


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	l = s.count('L')
	r = s.count('R')
	u = s.count('U')
	d = s.count('D')
	k = abs(l - r)
	p = abs(u - d)
	print(n - (k + p))


import sys
import math
from collections import Counter

def inputt():
	return sys.stdin.readline().strip()

def printt(n):
	sys.stdout.write(str(n) + '\n')

def listt():
	return [int(i) for i in inputt().split()]

def gcd(a, b):
	return math.gcd(a, b)

def lcm(a, b):
	return a * b / gcd(a, b)
t = int(inputt())

def SieveOfEratosthenes(n):
	s = 0
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 1
	prime[0] = False
	prime[1] = False
	for p in range(n + 1):
		if prime[p]:
			s += p
	l = list(str(s))
	print(l[-1])
for _ in range(t):
	n = int(inputt())
	s = inputt()
	dic = Counter(s)
	c = 0
	c += abs(dic['U'] - dic['D']) + abs(dic['L'] - dic['R'])
	printt(n - c)


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	s = input()
	c = Counter(s)
	print(min(c['L'], c['R']) * 2 + min(c['U'], c['D']) * 2)