Ivan has a robot which is situated on an infinite grid. Initially the robot is standing in the starting cell (0, 0). The robot can process commands. There are four types of commands it can perform:  U — move from the cell (x, y) to (x, y + 1);  D — move from (x, y) to (x, y - 1);  L — move from (x, y) to (x - 1, y);  R — move from (x, y) to (x + 1, y). 

Ivan entered a sequence of n commands, and the robot processed it. After this sequence the robot ended up in the starting cell (0, 0), but Ivan doubts that the sequence is such that after performing it correctly the robot ends up in the same cell. He thinks that some commands were ignored by robot. To acknowledge whether the robot is severely bugged, he needs to calculate the maximum possible number of commands that were performed correctly. Help Ivan to do the calculations!


-----Input-----

The first line contains one number n — the length of sequence of commands entered by Ivan (1 ≤ n ≤ 100).

The second line contains the sequence itself — a string consisting of n characters. Each character can be U, D, L or R.


-----Output-----

Print the maximum possible number of commands from the sequence the robot could perform to end up in the starting cell.


-----Examples-----
Input
4
LDUR

Output
4

Input
5
RRRUU

Output
0

Input
6
LLRRRR

Output
4

Source: codeforces | Difficulty: EASY
Tags: Greedy algorithms


Solutions:
n = int(input())
commands = input()
(dx, dy) = (0, 0)
for command in commands:
	if command == 'U':
		dy += 1
	elif command == 'D':
		dy -= 1
	elif command == 'L':
		dx -= 1
	elif command == 'R':
		dx += 1
(dx, dy) = (abs(dx), abs(dy))
print(n - dx - dy)


n = int(input())
s = input()
l = r = u = d = 0
for i in s:
	if i == 'L':
		l += 1
	elif i == 'R':
		r += 1
	elif i == 'D':
		d += 1
	else:
		u += 1
ans = min(l, r) * 2 + min(u, d) * 2
print(ans)


n = int(input())
a = [0] + list(input())
(x, y) = (0, 0)
an = 0
(ups, dwns, rts, lts) = (0, 0, 0, 0)
for i in range(n, 0, -1):
	if a[i] == 'U':
		ups += 1
	elif a[i] == 'D':
		dwns += 1
	elif a[i] == 'R':
		rts += 1
	else:
		lts += 1
	an = max(an, 2 * min(rts, lts) + 2 * min(ups, dwns))
print(an)


n = int(input())
s = input()
a = 0
b = 0
for x in s:
	if x == 'L':
		a += 1
	elif x == 'R':
		a -= 1
	elif x == 'U':
		b += 1
	else:
		b -= 1
s = abs(a) + abs(b)
print(n - s)


input()
s = input()
u = s.count('U')
d = s.count('D')
l = s.count('L')
r = s.count('R')
print(2 * min(u, d) + 2 * min(l, r))


n = int(input())
s = input()
x = 0
y = 0
for i in range(n):
	if s[i] == 'L':
		x -= 1
	elif s[i] == 'R':
		x += 1
	elif s[i] == 'U':
		y += 1
	elif s[i] == 'D':
		y -= 1
x = abs(x)
y = abs(y)
print(n - x - y)


a = int(input())
c = input()
x = 0
y = 0
for l in range(a):
	i = c[l]
	if i == 'U':
		y += 1
	elif i == 'L':
		x -= 1
	elif i == 'R':
		x += 1
	else:
		y -= 1
print(a - abs(x) - abs(y))


n = int(input())
c = input()
li = list(c)
r = li.count('R')
u = li.count('U')
d = li.count('D')
l = li.count('L')
cnt = 2 * min(r, l) + 2 * min(u, d)
print(cnt)


t = input()
s = input()
print(2 * min(s.count('R'), s.count('L')) + 2 * min(s.count('U'), s.count('D')))


i = input()
j = input()
u = j.count('U')
d = j.count('D')
l = j.count('L')
r = j.count('R')
ans = 2 * (min(u, d) + min(l, r))
print(ans)


n = int(input())
a = input()
x = 0
y = 0
l = 0
r = 0
u = 0
d = 0
for i in range(n):
	if a[i] == 'L':
		l = l + 1
	if a[i] == 'R':
		l = l - 1
	if a[i] == 'U':
		u = u + 1
	if a[i] == 'D':
		u = u - 1
print(n - abs(l) - abs(u))


n = int(input())
s = input()
s1 = 0
s2 = 0
f = 0
i = 0
l = []
l.append(0)
for i in range(len(s)):
	if s[i] == 'U':
		s1 += 1
	elif s[i] == 'D':
		s1 -= 1
	elif s[i] == 'L':
		s2 -= 1
	else:
		s2 += 1
print(len(s) - abs(s1) - abs(s2))


n = int(input())
l = list(input())
ans = abs(l.count('L') - l.count('R')) + abs(l.count('U') - l.count('D'))
print(n - ans)


n = int(input())
s = list(input())
d = 'UDLR'
cnt = {}
for c in d:
	cnt[c] = 0
for c in s:
	cnt[c] += 1
print(2 * (min(cnt['U'], cnt['D']) + min(cnt['L'], cnt['R'])))


n = int(input())
s = input()
left = 0
right = 0
up = 0
down = 0
for i in s:
	if i == 'U':
		up += 1
	elif i == 'D':
		down += 1
	elif i == 'L':
		left += 1
	else:
		right += 1
print(2 * min(left, right) + 2 * min(up, down))


n = input()
s = input()
print((min(s.count('L'), s.count('R')) + min(s.count('D'), s.count('U'))) * 2)


import sys
import math
input = sys.stdin.readline

def inp():
	return int(input())

def inara():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
n = inp()
command = insr()
x = 0
y = 0
for i in range(n):
	com = command[i]
	if com == 'L':
		x -= 1
	elif com == 'R':
		x += 1
	elif com == 'U':
		y += 1
	else:
		y -= 1
ans = abs(x) + abs(y)
print(n - ans)


n = int(input())
s = input()
l = 0
r = 0
u = 0
d = 0
for i in range(n):
	if s[i] == 'L':
		l += 1
	elif s[i] == 'R':
		r += 1
	elif s[i] == 'U':
		u += 1
	else:
		d += 1
print((min(l, r) + min(u, d)) * 2)


n = int(input())
s = input()
l = d = u = r = 0
for i in s:
	if i == 'L':
		l += 1
	if i == 'R':
		r += 1
	if i == 'U':
		u += 1
	if i == 'D':
		d += 1
print(min(u, d) * 2 + min(l, r) * 2)


import math
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
mod = 10 ** 9 + 7
mod1 = 998244353
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
l = list(input())
dx = 0
dy = 0
for i in range(n):
	if l[i] == 'R':
		dy += 1
	if l[i] == 'L':
		dy -= 1
	if l[i] == 'U':
		dx += 1
	if l[i] == 'D':
		dx -= 1
print(n - abs(dx) - abs(dy))


n = int(input())
s = input()
x1 = s.count('L')
x2 = s.count('R')
y1 = s.count('D')
y2 = s.count('U')
(r1, r2) = (0, 0)
if x1 != x2:
	r1 = max(x1, x2) - min(x1, x2)
if y1 != y2:
	r2 = max(y1, y2) - min(y1, y2)
k = r1 + r2
print(n - k)


n = int(input())
opers = list(input())
nR = opers.count('R')
nL = opers.count('L')
nU = opers.count('U')
nD = opers.count('D')
opnum = 2 * (min(nL, nR) + min(nD, nU))
print(int(opnum))


m = input()
n = str(input())
l = 0
u = 0
r = 0
d = 0
for i in range(len(n)):
	if n[i] == 'L':
		l += 1
	elif n[i] == 'U':
		u += 1
	elif n[i] == 'R':
		r += 1
	else:
		d += 1
print(2 * min(l, r) + 2 * min(u, d))


n = int(input())
s = input()
a = 4 * [0]
for i in range(n):
	if s[i] == 'U':
		a[0] += 1
	elif s[i] == 'D':
		a[1] += 1
	elif s[i] == 'L':
		a[2] += 1
	elif s[i] == 'R':
		a[3] += 1
print(n - abs(a[0] - a[1]) - abs(a[2] - a[3]))


from collections import Counter
n = int(input())
s = input()
d = Counter(s)
try:
	temp = min(d['U'], d['D'])
	d['U'] -= temp
	d['D'] -= temp
except KeyError:
	pass
try:
	temp = min(d['L'], d['R'])
	d['L'] -= temp
	d['R'] -= temp
except KeyError:
	pass
print(n - sum(list(d.values())))


from sys import stdin
n = int(stdin.readline())
trim = lambda s: s[:-1] if s[-1] == '\n' else s
moves = trim(stdin.readline())
x = 0
y = 0
for i in moves:
	if i == 'U':
		y += 1
	elif i == 'R':
		x += 1
	elif i == 'L':
		x -= 1
	elif i == 'D':
		y -= 1
print(len(moves) - abs(x) - abs(y))


import sys
n = int(input())
s = input()
print(min(s.count('U'), s.count('D')) * 2 + min(s.count('L'), s.count('R')) * 2)


n = int(input())
s = input()
l = list(s)
(L, R, U, D) = (l.count('L'), l.count('R'), l.count('U'), l.count('D'))
print(min(L, R) * 2 + min(U, D) * 2)


from collections import Counter
n = int(input())
C = Counter(input())
print(n - abs(C['L'] - C['R']) - abs(C['U'] - C['D']))


n = int(input())
a = list(input())
x = 0
y = 0
ans = n - abs(a.count('U') - a.count('D')) - abs(a.count('L') - a.count('R'))
if ans <= 0:
	print(0)
else:
	print(ans)


input()
a = [0] * 4
s = input()
for i in s:
	if i == 'U':
		a[0] += 1
	elif i == 'D':
		a[1] += 1
	elif i == 'L':
		a[2] += 1
	elif i == 'R':
		a[3] += 1
print(min(a[0], a[1]) * 2 + min(a[2], a[3]) * 2)


def main():
	n = int(input())
	seq = input()
	print(foo(seq))

def foo(seq):
	l = min(seq.count('L'), seq.count('R')) * 2
	r = min(seq.count('D'), seq.count('U')) * 2
	return l + r
main()


n = int(input())
s = input()
(k1, k2) = (0, 0)
for x in s:
	if x == 'U':
		k1 += 1
	if x == 'D':
		k1 -= 1
	if x == 'L':
		k2 += 1
	if x == 'R':
		k2 -= 1
print(n - (abs(k1) + abs(k2)))


n = int(input())
c = input()
x = 0
y = 0
for i in c:
	if i == 'L':
		x -= 1
	elif i == 'R':
		x += 1
	elif i == 'U':
		y += 1
	else:
		y -= 1
print(n - (abs(x) + abs(y)))


input()
inp = list(input().strip())
dic = {'L': 0, 'D': 0, 'U': 0, 'R': 0}
for i in inp:
	dic[i] += 1
count = 0
count += min(dic['L'], dic['R']) * 2
count += min(dic['U'], dic['D']) * 2
print(count)


b = int(input())
a = list(str([i for i in input().split()]))
l = a.count('L')
r = a.count('R')
u = a.count('U')
d = a.count('D')
if l > r:
	s = l - r
else:
	s = r - l
if u > d:
	x = u - d
else:
	x = d - u
print(l + r + u + d - s - x)


import sys
import math
n = int(input())
arr = input()
dx = 0
dy = 0
for i in arr:
	if i == 'L':
		dx -= 1
	elif i == 'R':
		dx += 1
	elif i == 'U':
		dy += 1
	else:
		dy -= 1
print(n - abs(dx) - abs(dy))


n = int(input())
comands = input()
u = comands.count('U')
d = comands.count('D')
l = comands.count('L')
r = comands.count('R')
print(n - abs(u - d) - abs(l - r))


n = int(input())
a = input()
print(n - (max(a.count('L'), a.count('R')) - min(a.count('L'), a.count('R'))) - (max(a.count('U'), a.count('D')) - min(a.count('U'), a.count('D')))) if n - (max(a.count('L'), a.count('R')) - min(a.count('L'), a.count('R'))) - (max(a.count('U'), a.count('D')) - min(a.count('U'), a.count('D'))) > 0 else print(0)


n = int(input())
cur = {'U': 0, 'D': 0, 'L': 0, 'R': 0}
commands = input()
for i in range(n):
	cur[commands[i]] += 1
print(min(cur['U'], cur['D']) * 2 + min(cur['L'], cur['R']) * 2)


import sys
n = int(input())
commands = str(input())
x = abs(commands.count('R') - commands.count('L'))
y = abs(commands.count('U') - commands.count('D'))
print(len(commands) - x - y)


f = lambda q: 2 * min(t.count(q[0]), t.count(q[1]))
input()
t = input()
print(f('UD') + f('LR'))


import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
mod = 10 ** 9 + 7

def lcm(x, y):
	return x * y / gcd(x, y)

def fact(x, mod=mod):
	ans = 1
	for i in range(1, x + 1):
		ans = ans * i % mod
	return ans

def arr2D(n, m, default=0):
	lst = []
	for i in range(n):
		temp = [default] * m
		lst.append(temp)
	return lst

def sortDictV(x):
	return {k: v for (k, v) in sorted(x.items(), key=lambda item: item[1])}

def solve(n, lst):
	(U, D, L, R) = (0, 0, 0, 0)
	for i in lst:
		if i == 'U':
			U += 1
		elif i == 'D':
			D += 1
		elif i == 'L':
			L += 1
		else:
			R += 1
	return 2 * min(U, D) + min(L, R) * 2
n = int(input())
lst = input()
print(solve(n, lst))


n = int(input())
e = list(input())
l = len(e)
L = e.count('L')
R = e.count('R')
U = e.count('U')
D = e.count('D')
if L > R or L < R:
	l = l - abs(L - R)
if U > D or U < D:
	l = l - abs(U - D)
print(l)


input()
a = input()
u = 0
d = 0
l = 0
r = 0
for c in a:
	if c == 'U':
		u += 1
	elif c == 'D':
		d += 1
	elif c == 'L':
		l += 1
	elif c == 'R':
		r += 1
print(min(u, d) * 2 + min(l, r) * 2)


x = int(input())
s = input()
ansl = 0
ansd = 0
for i in s:
	if i == 'L':
		ansl += 1
	if i == 'R':
		ansl -= 1
	if i == 'D':
		ansd += 1
	if i == 'U':
		ansd -= 1
ansl = abs(ansl)
ansd = abs(ansd)
print(x - (ansd + ansl))


n = int(input())
s = input()
print(n - (abs(s.count('R') - s.count('L')) + abs(s.count('U') - s.count('D'))))


n = int(input())
A = list(input())
u = 0
d = 0
l = 0
r = 0
for i in range(0, n):
	if A[i] == 'U':
		u += 1
	elif A[i] == 'D':
		d += 1
	elif A[i] == 'L':
		l += 1
	elif A[i] == 'R':
		r += 1
print(2 * min(u, d) + 2 * min(l, r))


n = int(input())
commands = input()
cnt = list((0 for _ in range(0, 5)))
for a in range(len(commands)):
	if commands[a] == 'L':
		cnt[0] += 1
	elif commands[a] == 'D':
		cnt[1] += 1
	elif commands[a] == 'U':
		cnt[2] += 1
	elif commands[a] == 'R':
		cnt[3] += 1
m1 = 101
m2 = 101
if cnt[0] > cnt[3]:
	m1 = cnt[3]
else:
	m1 = cnt[0]
if cnt[1] > cnt[2]:
	m2 = cnt[2]
else:
	m2 = cnt[1]
print(m1 * 2 + m2 * 2)


n = int(input())
s = input()
c = lambda i: s.count(i)
print(min(c('U'), c('D')) * 2 + min(c('L'), c('R')) * 2)


n = int(input())
s = input()
u = s.count('U')
d = s.count('D')
l = s.count('L')
r = s.count('R')
vert = min(u, d)
horz = min(r, l)
print((vert + horz) * 2)


def U(x, y):
	return (x, y + 1)

def D(x, y):
	return (x, y - 1)

def L(x, y):
	return (x - 1, y)

def R(x, y):
	return (x + 1, y)
num = int(input())
(x, y) = (0, 0)
com = {'U': U, 'D': D, 'L': L, 'R': R}
for i in input():
	(x, y) = com[i](x, y)
print(num - abs(x) - abs(y))


n = int(input())
a = list(input())
l = 0
r = 0
u = 0
d = 0
for i in a:
	if i == 'U':
		u += 1
	elif i == 'D':
		d += 1
	elif i == 'L':
		l += 1
	else:
		r += 1
print(min(l, r) * 2 + min(u, d) * 2)


import os
import sys
from io import BytesIO, IOBase
import math
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
s = input()
l = 0
r = 0
u = 0
d = 0
for i in range(n):
	if s[i] == 'L':
		l += 1
	elif s[i] == 'R':
		r += 1
	elif s[i] == 'U':
		u += 1
	else:
		d += 1
ans = 0
if u > 0 and d > 0:
	ans += min(u, d) * 2
if l > 0 and r > 0:
	ans += min(l, r) * 2
print(ans)


a = int(input())
s = input()
(r, l, u, d) = (0, 0, 0, 0)
res = 0
for i in s:
	if i == 'R':
		r += 1
	elif i == 'L':
		l += 1
	elif i == 'U':
		u += 1
	elif i == 'D':
		d += 1
res += min(r, l) * 2
res += min(u, d) * 2
print(res)


import math, sys
a = int(input())
ans = input()
cor = [0, 0]
arr = [0]
for i in range(a):
	if ans[i] == 'L':
		cor[0] -= 1
	elif ans[i] == 'R':
		cor[0] += 1
	elif ans[i] == 'U':
		cor[1] += 1
	elif ans[i] == 'D':
		cor[1] -= 1
print(a - (abs(cor[0]) + abs(cor[1])))


input()
a = input()
print((min(a.count('R'), a.count('L')) + min(a.count('U'), a.count('D'))) * 2)


def BuggyRobot(n, seq):
	x = 0
	y = 0
	for s in seq:
		if s == 'U':
			y += 1
		elif s == 'D':
			y -= 1
		elif s == 'L':
			x -= 1
		else:
			x += 1
	return n - abs(x) - abs(y)
n = int(input())
seq = input()
print(BuggyRobot(n, seq))


f = input()
a = [x for x in input()]
l = a.count('L')
r = a.count('R')
u = a.count('U')
d = a.count('D')

def min(*args):
	m = args[0]
	for i in args:
		if i < m:
			m = i
	return m
print(min(l, r) * 2 + min(u, d) * 2)


n = int(input())
s = input()
letters = {'U': 0, 'D': 0, 'L': 0, 'R': 0}
for ch in s:
	letters[ch] += 1
print((min(letters['U'], letters['D']) + min(letters['R'], letters['L'])) * 2)


N = int(input())
string = input()
counts = [0, 0, 0, 0]
for c in string:
	if c == 'U':
		counts[0] += 1
	elif c == 'D':
		counts[1] += 1
	elif c == 'L':
		counts[2] += 1
	elif c == 'R':
		counts[3] += 1
print(N - (abs(counts[0] - counts[1]) + abs(counts[2] - counts[3])))


length = int(input())
s = input()
num_l = s.count('L')
num_r = s.count('R')
num_u = s.count('U')
num_d = s.count('D')
val = 0
if num_l < num_r:
	val += num_l
else:
	val += num_r
if num_u < num_d:
	val += num_u
else:
	val += num_d
print(val * 2)


from collections import Counter
input()
c = Counter(input())
print(2 * (min(c['U'], c['D']) + min(c['L'], c['R'])))


x = int(input())
a = input()
R = 0
L = 0
U = 0
D = 0
for i in a:
	if i == 'U':
		U += 1
	if i == 'D':
		D += 1
	if i == 'L':
		L += 1
	if i == 'R':
		R += 1
p1 = 1
p2 = 1
if R < L:
	p1 = R * 2
else:
	p1 = L * 2
if D < U:
	p2 = D * 2
else:
	p2 = U * 2
print(p1 + p2)


n = int(input())
a = input()
c = lambda x: a.count(x)
(r, l, u, d) = (c('R'), c('L'), c('U'), c('D'))
print(n - abs(r - l) - abs(u - d))


n = int(input())
a = input()
l = [a.count('L'), a.count('R'), a.count('D'), a.count('U')]
print(min(l[0], l[1]) * 2 + min(l[2], l[3]) * 2)


import sys

def main():
	n = sys.stdin.readline()[:-1].split()
	args = list(sys.stdin.readline()[:-1])
	(x, y) = (0, 0)
	count = 0
	for move in args:
		if move == 'U':
			x += 1
		if move == 'D':
			x -= 1
		if move == 'L':
			y += 1
		if move == 'R':
			y -= 1
	if x > 0:
		flagX = 'U'
	else:
		flagX = 'D'
	if y > 0:
		flagY = 'L'
	else:
		flagY = 'R'
	(x, y) = (abs(x), abs(y))
	print(len(args) - x - y)
main()


n = int(input())
comands = input()
comands_list = list(comands)
u_kolvo = 0
d_kolvo = 0
r_kolvo = 0
l_kolvo = 0
kolvo = 0
for i in comands_list:
	if i == 'U':
		u_kolvo += 1
	elif i == 'D':
		d_kolvo += 1
	elif i == 'R':
		r_kolvo += 1
	elif i == 'L':
		l_kolvo += 1
if d_kolvo > u_kolvo:
	kolvo = (d_kolvo - (d_kolvo - u_kolvo)) * 2
elif u_kolvo > d_kolvo:
	kolvo = (u_kolvo - (u_kolvo - d_kolvo)) * 2
elif u_kolvo == d_kolvo:
	kolvo = u_kolvo + d_kolvo
if r_kolvo > l_kolvo:
	kolvo += (r_kolvo - (r_kolvo - l_kolvo)) * 2
elif l_kolvo > r_kolvo:
	kolvo += (l_kolvo - (l_kolvo - r_kolvo)) * 2
elif r_kolvo == l_kolvo:
	kolvo += r_kolvo + l_kolvo
print(kolvo)


n = int(input())
m = list(input())
a = m.count('U')
b = m.count('D')
c = m.count('L')
d = m.count('R')
e = min(a, b) * 2
f = min(c, d) * 2
print(e + f)


from collections import Counter
n = int(input())
x = input()
p = Counter(x)
ans = 0
if 'L' in p.keys() and 'R' in p.keys():
	ans = ans + min(p['L'], p['R'])
if 'U' in p.keys() and 'D' in p.keys():
	ans = ans + min(p['D'], p['U'])
print(ans * 2)


num_c = eval(input())
c_arr = input()
l = 0
r = 0
d = 0
u = 0
for i in range(0, num_c):
	if c_arr[i] == 'U':
		u += 1
	elif c_arr[i] == 'D':
		d += 1
	elif c_arr[i] == 'L':
		l += 1
	else:
		r += 1
print(2 * (min(l, r) + min(u, d)))


(N, X) = (int(input()), input())
print(N - (abs(X.count('L') - X.count('R')) + abs(X.count('U') - X.count('D'))))


n = int(input())
a = input()
x = 0
y = 0
for i in range(n):
	if a[i] == 'L':
		x -= 1
	elif a[i] == 'R':
		x += 1
	elif a[i] == 'D':
		y -= 1
	else:
		y += 1
print(n - abs(x) - abs(y))


input()
x = input()
print((min(x.count('L'), x.count('R')) + min(x.count('U'), x.count('D'))) * 2)


from sys import stdin, stdout
from collections import Counter

def ai():
	return list(map(int, stdin.readline().split()))

def ei():
	return map(int, stdin.readline().split())

def ip():
	return int(stdin.readline().strip())

def op(ans):
	return stdout.write(str(ans) + '\n')
n = ip()
s = [i for i in input()]
dx = dy = 0
for i in s:
	if i == 'R':
		dx += 1
	if i == 'L':
		dx -= 1
	if i == 'U':
		dy += 1
	if i == 'D':
		dy -= 1
print(n - abs(dx) - abs(dy))


n = int(input())
command = input()
U_count = command.count('U')
D_count = command.count('D')
L_count = command.count('L')
R_count = command.count('R')
print(2 * min(U_count, D_count) + 2 * min(L_count, R_count))


import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
N = int(input())
S = input()
(u, d, l, r) = (S.count('U'), S.count('D'), S.count('L'), S.count('R'))
print(N - abs(u - d) - abs(l - r))


moves = int(input())
comms = input()
x = 0
y = 0
for i in comms:
	if i == 'L':
		x -= 1
	if i == 'R':
		x += 1
	if i == 'U':
		y += 1
	if i == 'D':
		y -= 1
print(moves - (abs(x) + abs(y)))


n = int(input())
s = input()
A = {}
for i in s:
	if i == 'L':
		A[i] = A.get(i, 0) + 1
	if i == 'U':
		A[i] = A.get(i, 0) + 1
	if i == 'D':
		A[i] = A.get(i, 0) + 1
	if i == 'R':
		A[i] = A.get(i, 0) + 1
min1 = min(A.get('L', 0), A.get('R', 0))
min2 = min(A.get('U', 0), A.get('D', 0))
print(2 * (min1 + min2))


n = int(input())
s = input()
r = 0
u = 0
for i in s:
	if i == 'R':
		r += 1
	elif i == 'L':
		r -= 1
	elif i == 'U':
		u += 1
	else:
		u -= 1
print(n - (abs(r) + abs(u)))


y = [-1, 0, 1, 0]
x = [0, -1, 0, 1]
d = 'ULDR'
i = j = 0
n = int(input())
for c in input():
	v = d.index(c)
	i += y[v]
	j += x[v]
print(n - abs(i) - abs(j))


n = int(input())
seq = input()
result = 0
x = 0
y = 0
left = 0
right = 0
up = 0
down = 0
for i in range(n):
	if seq[i] is 'U':
		y += 1
		up += 1
	elif seq[i] is 'D':
		y -= 1
		down += 1
	elif seq[i] is 'L':
		x -= 1
		left += 1
	elif seq[i] is 'R':
		x += 1
		right += 1
if left > right:
	result += right * 2
else:
	result += left * 2
if up > down:
	result += down * 2
else:
	result += up * 2
print(result)


(h, v) = (0, 0)
n = int(input())
command = input()
for i in range(len(command)):
	if command[i] == 'U':
		v += 1
	elif command[i] == 'D':
		v -= 1
	elif command[i] == 'L':
		h -= 1
	elif command[i] == 'R':
		h += 1
print(len(command) - abs(h) - abs(v))


def main():
	input()
	nums = list(input())
	letters_u = nums.count('U')
	letters_d = nums.count('D')
	letters_l = nums.count('L')
	letters_r = nums.count('R')
	return min([letters_r, letters_l]) * 2 + min([letters_d, letters_u]) * 2
print(main())


n = int(input())
x = input()
xs = 0
ys = 0
for j in x:
	if j == 'U':
		ys += 1
	elif j == 'D':
		ys -= 1
	elif j == 'R':
		xs += 1
	elif j == 'L':
		xs -= 1
print(n - abs(xs) - abs(ys))


n = int(input())
a = input()
(l, r, u, d) = (0, 0, 0, 0)
for i in a:
	if i == 'L':
		l += 1
	elif i == 'R':
		r += 1
	elif i == 'U':
		u += 1
	else:
		d += 1
lr = l
if lr > r:
	lr = r
ud = u
if ud > d:
	ud = d
print(2 * (ud + lr))


n = int(input())
s = input()
ver = 0
hor = 0
for c in s:
	if c == 'U':
		ver += 1
	elif c == 'D':
		ver -= 1
	elif c == 'R':
		hor += 1
	else:
		hor -= 1
print(n - abs(ver) - abs(hor))


n = int(input())
a = [0, 0, 0, 0]
m = {'L': 0, 'R': 1, 'D': 2, 'U': 3}
for c in input():
	a[m[c]] += 1
print(min(a[0], a[1]) * 2 + min(a[2], a[3]) * 2)


n = int(input())
s = input()
a = 0
if s.count('R') != 0 and s.count('L') != 0:
	a += min(s.count('L'), s.count('R')) * 2
if s.count('U') != 0 and s.count('D') != 0:
	a += min(s.count('D'), s.count('U')) * 2
print(a)


n = int(input())
s = input()
(l, r) = (0, 0)
for i in range(n):
	if s[i] == 'U':
		r += 1
	elif s[i] == 'D':
		r -= 1
	elif s[i] == 'L':
		l -= 1
	elif s[i] == 'R':
		l += 1
print(n - (abs(l) + abs(r)))


size = int(input())
s = input()
print(2 * min(s.count('L'), s.count('R')) + 2 * min(s.count('U'), s.count('D')))


n = int(input())
string = input()
i = 0
while i < len(string) - 1:
	if string[i] == 'U' and 'D' in string:
		string = string[:i] + string[i + 1:]
		d = string.find('D')
		string = string[:d] + string[d + 1:]
	elif string[i] == 'D' and 'U' in string:
		string = string[:i] + string[i + 1:]
		d = string.find('U')
		string = string[:d] + string[d + 1:]
	elif string[i] == 'L' and 'R' in string:
		string = string[:i] + string[i + 1:]
		d = string.find('R')
		string = string[:d] + string[d + 1:]
	elif string[i] == 'R' and 'L' in string:
		string = string[:i] + string[i + 1:]
		d = string.find('L')
		string = string[:d] + string[d + 1:]
	else:
		i += 1
print(n - len(string))


n = int(input())
s = input()
pos = [0, 0]
ans = [0, 0, 0, 0]
s1 = 'UDLR'
for i in s:
	ans[s1.index(i)] += 1
print(2 * (min(ans[:2]) + min(ans[2:])))


import sys
str = sys.stdin.read()
lc = 0
rc = 0
uc = 0
dc = 0
for char in str:
	if char == 'U':
		uc += 1
	elif char == 'D':
		dc += 1
	elif char == 'L':
		lc += 1
	elif char == 'R':
		rc += 1
print(2 * min(uc, dc) + 2 * min(lc, rc))


import sys
n = int(sys.stdin.readline())
s = sys.stdin.readline().rstrip()
(u, r, d, l) = (s.count('U'), s.count('R'), s.count('D'), s.count('L'))
print(n - (abs(u - d) + abs(r - l)))


n = int(input())
a = input()
(p, q, r, s) = (a.count('L'), a.count('R'), a.count('U'), a.count('D'))
print(2 * (min(p, q) + min(r, s)))


input()
S = input()
LDUR = [0] * 4
for c in S:
	if c == 'L':
		LDUR[0] += 1
	elif c == 'D':
		LDUR[1] += 1
	elif c == 'U':
		LDUR[2] += 1
	else:
		LDUR[3] += 1
print(2 * min(LDUR[0], LDUR[3]) + 2 * min(LDUR[2], LDUR[1]))


n = int(input())
s = input()
x = 0
y = 0
d = {'L': 0, 'R': 0, 'U': 0, 'D': 0}
for c in s:
	d[c] += 1
print(2 * (min(d['U'], d['D']) + min(d['L'], d['R'])))


n = int(input())
s = input()
a = 0
b = 0
l = len(s)
for i in range(l):
	if s[i] == 'U':
		a += 1
	if s[i] == 'D':
		a += -1
	if s[i] == 'L':
		b -= 1
	if s[i] == 'R':
		b += 1
print(n - (abs(b) + abs(a)))


n = int(input())
s = input()
u = s.count('U')
d = s.count('D')
r = s.count('R')
l = s.count('L')
x = min(u, d)
y = min(l, r)
print(2 * x + 2 * y)


s = input()[:0] + input()
print(min(s.count('L'), s.count('R')) * 2 + min(s.count('U'), s.count('D')) * 2)


n = int(input())
a = input()
U = 0
D = 0
L = 0
R = 0
for i in range(n):
	if a[i] == 'L':
		L += 1
	elif a[i] == 'D':
		D += 1
	elif a[i] == 'U':
		U += 1
	else:
		R += 1
print(min(U, D) * 2 + min(L, R) * 2)


def robot(s):
	(count1, count2, count3, count4) = (0, 0, 0, 0)
	for elem in s:
		if elem == 'L':
			count1 += 1
		if elem == 'R':
			count2 += 1
		if elem == 'U':
			count3 += 1
		if elem == 'D':
			count4 += 1
	return 2 * min(count1, count2) + 2 * min(count3, count4)
n = int(input())
t = input()
print(robot(t))


n = int(input())
s = input()
l = s.count('L')
r = s.count('R')
u = s.count('U')
d = s.count('D')
k = 0
m = 0
if l != 0 and r != 0:
	k = min(l, r) * 2
if u != 0 and d != 0:
	m = min(u, d) * 2
print(k + m)


lenght = input()
moves = input()
print(min(moves.count('U'), moves.count('D')) * 2 + min(moves.count('L'), moves.count('R')) * 2)


n = int(input())
temp = input()
L = temp.count('L')
D = temp.count('D')
U = temp.count('U')
R = temp.count('R')
s = 2 * min(L, R) + 2 * min(U, D)
print(s)


import sys
import math
import bisect
import itertools
import random
import re

def main():
	d = {'U': 0, 'D': 0, 'L': 0, 'R': 0}
	n = int(input())
	for c in input():
		d[c] += 1
	ans = 0
	ans += min(d['U'], d['D']) * 2
	ans += min(d['L'], d['R']) * 2
	print(ans)
main()


n = int(input())
s = input()
l = s.count('L')
r = s.count('R')
u = s.count('U')
d = s.count('D')
ans = 2 * min(u, d) + 2 * min(l, r)
print(ans)


input()
s = input()
up = s.count('U')
down = s.count('D')
left = s.count('L')
right = s.count('R')
print(2 * (min(up, down) + min(left, right)))


n = int(input())
s = input()
d = {'L': (-1, 0), 'U': (0, 1), 'D': (0, -1), 'R': (1, 0)}
(u, v) = (0, 0)
for c in s:
	u += d[c][0]
	v += d[c][1]
print(n - abs(u) - abs(v))


n = int(input())
c = list(input())
cmds = 0
while True:
	f = True
	if c.count('L') > 0 and c.count('R') > 0:
		c.remove('L')
		c.remove('R')
		cmds += 2
		f = False
	if c.count('U') > 0 and c.count('D') > 0:
		c.remove('U')
		c.remove('D')
		cmds += 2
		f = False
	if f:
		break
print(cmds)


n = int(input())
s = input()
res = 0
f = s.count
res += 2 * min(f('R'), f('L'))
res += 2 * min(f('U'), f('D'))
print(res)


n = input()
arr = input()
dc = {'U': 0, 'D': 0, 'L': 0, 'R': 0}
for i in arr:
	dc[i] += 1
print(2 * (min(dc['U'], dc['D']) + min(dc['L'], dc['R'])))


n = int(input())
s = input()
vertical = ['U', 'D']
horizontal = ['L', 'R']
count = 0
for direction in [horizontal, vertical]:
	u = [0, 0]
	for j in range(n):
		for i in range(2):
			if s[j] == direction[i]:
				u[i] += 1
	count += 2 * min(u[0], u[1])
print(count)


n = int(input())
string = input()
arr = [str(i) for i in string][:n]
left = right = up = down = 0
for i in arr:
	if i == 'L':
		left += 1
	elif i == 'R':
		right += 1
	elif i == 'U':
		up += 1
	elif i == 'D':
		down += 1
print(2 * (min(left, right) + min(up, down)))


n = int(input())
program = input()
print(2 * (min(program.count('U'), program.count('D')) + min(program.count('L'), program.count('R'))))


input()
k = input()
print((min(k.count('R'), k.count('L')) + min(k.count('D'), k.count('U'))) * 2)


n = int(input())
instructions = input()
left = 0
right = 0
up = 0
down = 0
for i in instructions:
	if i == 'L':
		left += 1
	elif i == 'R':
		right += 1
	elif i == 'U':
		up += 1
	elif i == 'D':
		down += 1
print((min(left, right) + min(up, down)) * 2)


n = int(input())
s = input()
u = 0
d = 0
r = 0
l = 0
for q in range(n):
	if s[q] == 'L':
		l = l + 1
	elif s[q] == 'R':
		r = r + 1
	elif s[q] == 'U':
		u = u + 1
	elif s[q] == 'D':
		d = d + 1
print(min(r, l) * 2 + min(u, d) * 2)


def main():
	n = int(input())
	s = input()
	print(2 * min(s.count('L'), s.count('R')) + 2 * min(s.count('U'), s.count('D')))
main()


from sys import stdin
n = int(stdin.readline())
moves = stdin.readline()
lr = 0
ud = 0
for c in moves:
	if c == 'L':
		lr += 1
	if c == 'R':
		lr -= 1
	if c == 'U':
		ud += 1
	if c == 'D':
		ud -= 1
print(n - abs(lr) - abs(ud))


n = int(input())
cs = input()
cc = {'U': 0, 'D': 0, 'L': 0, 'R': 0}
for c in cs:
	cc[c] += 1
total = n - abs(cc['U'] - cc['D']) - abs(cc['L'] - cc['R'])
print(total)


num = int(input())
data = list(input())
x = 0
y = 0
for com in data:
	if com == 'U':
		y += 1
	elif com == 'D':
		y -= 1
	elif com == 'L':
		x += 1
	elif com == 'R':
		x -= 1
print(num - (abs(x) + abs(y)))


n = int(input())
s = input()
(a, b) = (0, 0)
for i in s:
	if i == 'L':
		a -= 1
	elif i == 'R':
		a += 1
	elif i == 'D':
		b -= 1
	else:
		b += 1
print(len(s) - abs(a) - abs(b))


N = int(input())
array = list(input())
(vertical, horizontal) = (0, 0)
for i in range(N):
	if array[i] == 'L':
		horizontal -= 1
	if array[i] == 'R':
		horizontal += 1
	if array[i] == 'U':
		vertical += 1
	if array[i] == 'D':
		vertical -= 1
print(N - (abs(vertical) + abs(horizontal)))


num = int(input())
string = input()
u = string.count('U')
d = string.count('D')
l = string.count('L')
r = string.count('R')
print(2 * min(u, d) + 2 * min(l, r))


n = int(input())
command = input()
command = [com for com in command]
(x, y) = (0, 0)
for com in command:
	if com == 'U':
		y += 1
	if com == 'D':
		y -= 1
	if com == 'R':
		x += 1
	if com == 'L':
		x -= 1
print(n - abs(x) - abs(y))


n = int(input())
s = input()
num_R = 0
num_L = 0
num_U = 0
num_D = 0
for i in range(n):
	if s[i] == 'R':
		num_R += 1
	elif s[i] == 'L':
		num_L += 1
	elif s[i] == 'U':
		num_U += 1
	else:
		num_D += 1
ans = min(num_L, num_R) * 2 + min(num_U, num_D) * 2
print(ans)


input()
s = input()
nl = nr = nd = nu = 0
for ch in s:
	if ch == 'U':
		nu += 1
	elif ch == 'D':
		nd += 1
	elif ch == 'L':
		nl += 1
	elif ch == 'R':
		nr += 1
print(min(nl, nr) * 2 + min(nd, nu) * 2)


num = int(input())
seq = input()
l = d = u = r = 0
for c in seq:
	if c == 'L':
		l += 1
	elif c == 'D':
		d += 1
	elif c == 'U':
		u += 1
	else:
		r += 1
res = min(l, r)
res += min(u, d)
res = res * 2
print(res)


_ = input()
temp = input()
print(min(temp.count('L'), temp.count('R')) * 2 + min(temp.count('U'), temp.count('D')) * 2)


def main(n, s):
	uds = True
	lrs = True
	s = list(s)
	while uds == True or lrs == True:
		if 'U' in s and 'D' in s:
			s.pop(s.index('U'))
			s.pop(s.index('D'))
		else:
			uds = False
		if 'L' in s and 'R' in s:
			s.pop(s.index('L'))
			s.pop(s.index('R'))
		else:
			lrs = False
	print(n - len(s))
num = int(input())
main(num, input())


def robot(string):
	if 'U' in string and 'D' in string and ('R' in string) and ('L' in string):
		return min(string.count('U'), string.count('D')) * 2 + min(string.count('R'), string.count('L')) * 2
	if 'U' in string and 'D' in string:
		return min(string.count('U'), string.count('D')) * 2
	if 'R' in string and 'L' in string:
		return min(string.count('R'), string.count('L')) * 2
	if 'U' in string and 'D' not in string:
		return 0
	if 'D' in string and 'U' not in string:
		return 0
	if 'R' in string and 'L' not in string:
		return 0
	if 'L' in string and 'R' not in string:
		return 0
t = int(input())
print(robot(input()))


n = input()
a = input()
hor = 0
vert = 0
for char in a:
	if char == 'U':
		vert += 1
	elif char == 'D':
		vert -= 1
	elif char == 'L':
		hor -= 1
	else:
		hor += 1
print(int(n) - (abs(hor) + abs(vert)))


n = int(input())
ops = input()
l = ops.count('L')
r = ops.count('R')
u = ops.count('U')
d = ops.count('D')
print(min(l, r) * 2 + min(u, d) * 2)


n = int(input())
a = input()
u = a.count('U')
d = a.count('D')
l = a.count('L')
r = a.count('R')
diff_u_d = abs(u - d)
diff_l_r = abs(l - r)
print(n - (diff_l_r + diff_u_d))


n = int(input())
s = input()
a = min(s.count('U'), s.count('D')) * 2
b = min(s.count('R'), s.count('L')) * 2
print(a + b)


n = int(input())
s = input()
s = list(s)
dx = 0
dy = 0
for i in range(n):
	if s[i] == 'L':
		dx -= 1
	elif s[i] == 'R':
		dx += 1
	elif s[i] == 'U':
		dy += 1
	else:
		dy -= 1
print(n - abs(dx) - abs(dy))


n = int(input())
s = input()
l = [0, 0]
for x in s:
	if x == 'U':
		l[1] += 1
	elif x == 'D':
		l[1] -= 1
	elif x == 'L':
		l[0] -= 1
	else:
		l[0] += 1
print(n - abs(l[0]) - abs(l[1]))


n = int(input())
a = list(input().strip())
x = 0
y = 0
for i in range(n):
	if a[i] == 'L':
		x -= 1
	elif a[i] == 'R':
		x += 1
	elif a[i] == 'U':
		y -= 1
	elif a[i] == 'D':
		y += 1
print(max(0, n - abs(x) - abs(y)))


def solve(x, y, ind):
	if x == 103 and y == 103 and (ind == n):
		return 0
	if ind == n:
		return -ind
	if dp[x][y][ind] != -1:
		return dp[x][y][ind]
	ans = 0
	ans = solve(x, y, ind + 1)
	if c[ind] == 'L':
		ans = max(ans, 1 + solve(x - 1, y, ind + 1))
	elif c[ind] == 'R':
		ans = max(ans, 1 + solve(x + 1, y, ind + 1))
	elif c[ind] == 'U':
		ans = max(ans, 1 + solve(x, y - 1, ind + 1))
	else:
		ans = max(ans, 1 + solve(x, y + 1, ind + 1))
	dp[x][y][ind] = ans
	return ans
n = int(input())
c = input()
dp = [[[-1] * (n + 1) for i in range(205)] for j in range(205)]
print(solve(103, 103, 0))


import sys, math, queue, bisect
MOD = 10 ** 9 + 7
sys.setrecursionlimit(1000000)
n = int(input())
s = input()
d = {'L': 0, 'R': 0, 'U': 0, 'D': 0}
for c in s:
	d[c] += 1
print(2 * min(d['L'], d['R']) + 2 * min(d['U'], d['D']))


import sys
n = int(input())
s = input()
R = L = U = D = 0
for ch in s:
	if ch == 'R':
		R += 1
	elif ch == 'L':
		L += 1
	elif ch == 'U':
		U += 1
	else:
		D += 1
ans = 0
ans += min(D, U) * 2
ans += min(R, L) * 2
print(ans)


n = int(input())
s = input()
x = 0
y = 0
for c in s:
	if c == 'U':
		y -= 1
	if c == 'D':
		y += 1
	if c == 'L':
		x -= 1
	if c == 'R':
		x += 1
print(n - abs(x) - abs(y))


n = int(input())
d = {}
for c in input():
	d.setdefault(c, 0)
	d[c] += 1
ans = min(d.get('L', 0), d.get('R', 0)) + min(d.get('U', 0), d.get('D', 0))
print(ans * 2)


n = int(input())
a = list(input())
u = 0
d = 0
l = 0
r = 0
for i in range(n):
	if a[i] == 'L':
		l = l + 1
	if a[i] == 'R':
		r = r + 1
	if a[i] == 'D':
		d = d + 1
	if a[i] == 'U':
		u = u + 1
count = 0
while u > 0 and d > 0:
	count = count + 2
	u = u - 1
	d = d - 1
while l > 0 and r > 0:
	count = count + 2
	l = l - 1
	r = r - 1
print(count)


n = int(input())
commands = input()
(current_x, current_y) = (0, 0)
for i in range(n):
	if commands[i] == 'U':
		current_y += 1
	elif commands[i] == 'D':
		current_y -= 1
	elif commands[i] == 'L':
		current_x -= 1
	else:
		current_x += 1
print(n - (abs(current_y) + abs(current_x)))


x = int(input())
n = input()
count = 0
l = n.count('L')
r = n.count('R')
u = n.count('U')
d = n.count('D')
if l < r:
	count = count + l * 2
else:
	count = count + r * 2
if u < d:
	count = count + u * 2
else:
	count = count + d * 2
print(count)


n = int(input())
string = list(input())
print(min(string.count('U'), string.count('D')) * 2 + min(string.count('L'), string.count('R')) * 2)


n = int(input())
x = input()
position = [0, 0]
for i in range(n):
	if x[i] == 'U':
		position[1] += 1
	if x[i] == 'D':
		position[1] -= 1
	if x[i] == 'L':
		position[0] -= 1
	if x[i] == 'R':
		position[0] += 1
print(n - abs(position[0]) - abs(position[1]))


n = int(input())
com = input().strip()
count = [0] * 4
for i in range(0, n):
	if com[i] == 'U':
		count[0] = count[0] + 1
	elif com[i] == 'D':
		count[1] = count[1] + 1
	if com[i] == 'L':
		count[2] = count[2] + 1
	if com[i] == 'R':
		count[3] = count[3] + 1
u = min(count[0], count[1])
l = min(count[2], count[3])
ans = u * 2 + l * 2
print(ans)


x = int(input())
array = input()
position = [0, 0]
output = 0
change = 0
for i in array:
	if i == 'U':
		position[1] += 1
	elif i == 'D':
		position[1] -= 1
	elif i == 'R':
		position[0] += 1
	elif i == 'L':
		position[0] -= 1
for j in range(len(array)):
	if array[j] == 'R' and position[0] > 0:
		position[0] -= 1
		change += 1
	elif array[j] == 'L' and position[0] < 0:
		position[0] += 1
		change += 1
	elif array[j] == 'U' and position[1] > 0:
		position[1] -= 1
		change += 1
	elif array[j] == 'D' and position[1] < 0:
		position[1] += 1
		change += 1
if position == [0, 0]:
	output = x - change
print(output)


n = int(input())
l = list(input())
e = l.count('L')
f = l.count('R')
g = l.count('U')
h = l.count('D')
c = 0
c += min(e, f)
c += min(g, h)
print(c * 2)


n = input()
l = input()
print(2 * (min(l.count('U'), l.count('D')) + min(l.count('L'), l.count('R'))))


n = int(input())
s = str(input())
x = min(s.count('R'), s.count('L'))
y = min(s.count('U'), s.count('D'))
print(2 * (x + y))


n = int(input())
s = input()
x = [0 for i in range(4)]
for i in range(n):
	if s[i] == 'U':
		x[0] += 1
	elif s[i] == 'D':
		x[1] += 1
	elif s[i] == 'L':
		x[2] += 1
	else:
		x[3] += 1
print(min(x[0], x[1]) * 2 + min(x[2], x[3]) * 2)


n = int(input())
a = list(input())
x = y = 0
count = {}
for c in a:
	if c not in count:
		count[c] = 0
	count[c] += 1
print(2 * (min(count.get('L', 0), count.get('R', 0)) + min(count.get('U', 0), count.get('D', 0))))


n = input()
S = input()
cts = {'L': 0, 'R': 0, 'U': 0, 'D': 0}
r = 0
for c in S:
	if c == 'L':
		if cts['R'] > 0:
			r += 2
			cts['R'] -= 1
		else:
			cts['L'] += 1
	if c == 'R':
		if cts['L'] > 0:
			r += 2
			cts['L'] -= 1
		else:
			cts['R'] += 1
	if c == 'U':
		if cts['D'] > 0:
			r += 2
			cts['D'] -= 1
		else:
			cts['U'] += 1
	if c == 'D':
		if cts['U'] > 0:
			r += 2
			cts['U'] -= 1
		else:
			cts['D'] += 1
print(r)


from __future__ import division, print_function
import sys
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
if os.path.exists('in.txt'):
	sys.stdin = open('in.txt', 'r')
if os.path.exists('out.txt'):
	sys.stdout = open('out.txt', 'w')

def input():
	return sys.stdin.readline()

def mapi(arg=0):
	return map(int if arg == 0 else str, input().split())
n = int(input())
a = input().strip()
res = 0
x = 0
y = 0
cnt = 0
print(2 * (min(a.count('L'), a.count('R')) + min(a.count('D'), a.count('U'))))


def main():
	input()
	commands = input()
	right = commands.count('R')
	left = commands.count('L')
	up = commands.count('U')
	down = commands.count('D')
	result = right + left - abs(right - left) + up + down - abs(up - down)
	print(result)
main()


n = int(input())
c = str(input())
print(min(c.count('L'), c.count('R')) * 2 + min(c.count('U'), c.count('D')) * 2)


a = int(input())
b = input()
U = b.count('U')
D = b.count('D')
L = b.count('L')
R = b.count('R')
count = a - (max(U, D) - min(U, D)) - (max(L, R) - min(L, R))
print(count)


def list_output(s):
	print(' '.join(map(str, s)))

def list_input():
	return list(map(int, input().split()))
n = int(input())
s = input()
(l, r, u, d) = (0, 0, 0, 0)
for i in range(n):
	if s[i] == 'L':
		l += 1
	elif s[i] == 'R':
		r += 1
	elif s[i] == 'U':
		u += 1
	elif s[i] == 'D':
		d += 1
res = 2 * min(l, r) + 2 * min(u, d)
print(res)


input()
arr = input()
U = arr.count('U')
D = arr.count('D')
R = arr.count('R')
L = arr.count('L')
print(len(arr) - abs(U - D) - abs(L - R))


n = int(input())
s = input()
dx = {'L': -1, 'R': 1}
dy = {'U': 1, 'D': -1}
(x, y) = (0, 0)
for i in s:
	if i in 'LR':
		x += dx.get(i)
	else:
		y += dy.get(i)
print(n - abs(x) - abs(y))


import math
from sys import stdin
number = int(stdin.readline())
string = stdin.readline()
output = 0
position = [0, 0]

def direction(d):
	global step
	global output
	if d == 'L':
		position[0] -= 1
	elif d == 'R':
		position[0] += 1
	elif d == 'U':
		position[1] += 1
	elif d == 'D':
		position[1] -= 1
for D in string:
	direction(D)
output = number - abs(position[0]) - abs(position[1])
print(output)


import math
from math import gcd, floor, sqrt, log

def iin():
	return int(input())

def sin():
	return input().strip()

def listin():
	return list(map(int, input().strip().split()))

def liststr():
	return list(map(str, input().strip().split()))

def ceill(x):
	return int(x) if x == int(x) else int(x) + 1

def ceilldiv(x, d):
	return x // d if x % d == 0 else x // d + 1

def LCM(a, b):
	return a * b // gcd(a, b)

def solve():
	n = iin()
	s = sin()
	count = {'R': 0, 'L': 0, 'U': 0, 'D': 0}
	temp = [0, 0]
	for i in s:
		count[i] += 1
	diff = abs(count['R'] - count['L']) + abs(count['U'] - count['D'])
	print(n - diff)
t = 1
for hula in range(t):
	solve()


import sys, math
from collections import defaultdict, Counter

def li():
	return list(map(int, sys.stdin.readline().split()))

def ls():
	return list(map(int, list(input())))

def la():
	return list(input())

def ii():
	return int(input())
n = li()
s = Counter(la())
l = min(s['L'], s['R'])
u = min(s['U'], s['D'])
print(2 * l + 2 * u)


n = int(input())
s = input()
(h, v) = (0, 0)
for i in range(len(s)):
	if s[i] == 'L':
		h -= 1
	elif s[i] == 'R':
		h += 1
	elif s[i] == 'D':
		v -= 1
	else:
		v += 1
h = abs(h)
v = abs(v)
delta = len(s) - h - v
print(delta)


from collections import deque, defaultdict, Counter
from itertools import product, groupby, permutations, combinations
from math import gcd, floor, inf
from bisect import bisect_right, bisect_left
n = int(input())
s = input()
ans = 0
x = y = 0
for (i, char) in enumerate(s, start=1):
	if char == 'R':
		x += 1
	elif char == 'L':
		x -= 1
	elif char == 'U':
		y += 1
	elif char == 'D':
		y -= 1
off = abs(x) + abs(y)
print(n - off)


from collections import Counter
num_moves = int(input())
move_count = Counter(input())
print(num_moves - abs(move_count['R'] - move_count['L']) - abs(move_count['U'] - move_count['D']))


import math
n = int(input())
s = input()
dp = [0, 0, 0, 0]
for i in s:
	if i == 'L':
		dp[0] += 1
	elif i == 'R':
		dp[1] += 1
	elif i == 'U':
		dp[2] += 1
	else:
		dp[3] += 1
print(2 * (min(dp[0], dp[1]) + min(dp[2], dp[3])))


n = int(input())
s = input()
(u, d, l, r) = (0, 0, 0, 0)
for i in range(0, n):
	if s[i] == 'U':
		u += 1
	if s[i] == 'D':
		d += 1
	if s[i] == 'L':
		l += 1
	if s[i] == 'R':
		r += 1
e = n - (abs(u - d) + abs(l - r))
print(e)


n = int(input())
l = input()
xs = 0
ys = 0
print(2 * (min(l.count('U'), l.count('D')) + min(l.count('L'), l.count('R'))))


n = int(input())
moves = list(input())

def robo(n, moves):
	L = moves.count('L')
	D = moves.count('D')
	U = moves.count('U')
	R = moves.count('R')
	return 2 * (min(L, R) + min(D, U))
assert robo(4, 'LDUR') == 4
assert robo(5, 'RRRUU') == 0
assert robo(6, 'LLRRRR') == 4
print(robo(n, moves))


x = 0
y = 0
U = 0
D = 0
L = 0
R = 0
n = int(input())
s = input()
for i in s:
	exec(i + '+=1')
print(min(U, D) * 2 + min(L, R) * 2)


n = int(input())
data = input()
ans = 0
count = {'U': 0, 'D': 0, 'L': 0, 'R': 0}
for c in data:
	count[c] += 1
ans += min([count['U'], count['D']]) * 2 + min([count['L'], count['R']]) * 2
print(str(ans))


c = input()
s = input()
counter = 0
a = [s.count(element) for element in 'UDLR']
if a[0] != 0 and a[1] != 0:
	counter += min(a[0], a[1])
if a[2] != 0 and a[3] != 0:
	counter += min(a[2], a[3])
print(counter * 2)


(n, c, x, y, j) = (int(input()), 0, 0, 0, 0)
n = str(input())
print((min(n.count('L'), n.count('R')) + min(n.count('U'), n.count('D'))) * 2)


from math import gcd, ceil
from collections import defaultdict as dd

def lcm(a, b):
	return a * b // gcd(a, b)

def inin():
	return int(input())

def inar():
	return list(map(int, input().split()))

def ar(element, size):
	return [element for i in range(size)]

def digitsum(num):
	su = 0
	while num:
		su += num % 10
		num //= 10
	return su
n = inin()
moves = input()
l = 0
r = 0
u = 0
d = 0
for i in moves:
	if i == 'L':
		l += 1
	if i == 'R':
		r += 1
	if i == 'U':
		u += 1
	if i == 'D':
		d += 1
print(n - (abs(l - r) + abs(u - d)))


int(input())
a = input()
(r, l, u, d) = (0, 0, 0, 0)
for _ in range(len(a)):
	if a[_] == 'R':
		r = r + 1
	if a[_] == 'L':
		l = l + 1
	if a[_] == 'U':
		u = u + 1
	if a[_] == 'D':
		d = d + 1
print(len(a) - abs(l - r) - abs(u - d))


n = int(input())
commands = input()
left = r = u = d = 0
for c in commands:
	if c == 'L':
		left += 1
	elif c == 'D':
		d += 1
	elif c == 'U':
		u += 1
	else:
		r += 1
print(n - (abs(left - r) + abs(u - d)))


N = int(input())
S = str(input())
A = [0, 0]
for i in S:
	if i == 'U':
		A[1] += 1
	elif i == 'D':
		A[1] -= 1
	elif i == 'L':
		A[0] -= 1
	elif i == 'R':
		A[0] += 1
while A != [0, 0]:
	if A[0] > 0:
		A[0] -= 1
		N -= 1
	elif A[0] < 0:
		A[0] += 1
		N -= 1
	elif A[1] > 0:
		A[1] -= 1
		N -= 1
	elif A[1] < 0:
		A[1] += 1
		N -= 1
print(N)


from collections import Counter, defaultdict
R = lambda : map(int, input().split())
(n, s) = (int(input()), input())
ct = Counter(s)
print(2 * min(ct.get('U', 0), ct.get('D', 0)) + 2 * min(ct.get('L', 0), ct.get('R', 0)))


n = int(input())
commands = input()
udlr = [0, 0, 0, 0]
for x in commands:
	if x == 'U':
		udlr[0] += 1
	elif x == 'D':
		udlr[1] += 1
	elif x == 'L':
		udlr[2] += 1
	else:
		udlr[3] += 1
ans = min(udlr[0], udlr[1]) * 2 + min(udlr[2], udlr[3]) * 2
print(ans)


n = int(input())
Sstr = input()
a = 0
b = 0
for i in range(len(Sstr)):
	if Sstr[i] == 'L':
		a += 1
	elif Sstr[i] == 'R':
		a -= 1
	elif Sstr[i] == 'U':
		b += 1
	else:
		b -= 1
print(n - abs(a) - abs(b))


n = int(input())
s = input()
d = {'L': 0, 'D': 0, 'U': 0, 'R': 0}
for i in s:
	d[i] += 1
print(min(d['L'], d['R']) * 2 + min(d['U'], d['D']) * 2)


n = int(input())
k = input()
q = [0, 0, 0, 0]
for i in k:
	if i == 'U':
		q[0] += 1
	if i == 'D':
		q[1] += 1
	if i == 'L':
		q[2] += 1
	if i == 'R':
		q[3] += 1
print(min(q[0], q[1]) * 2 + min(q[2], q[3]) * 2)


n = int(input())
s = list(input())
ans = 0
for i in range(n):
	if s.count('L') > 0 and s.count('R') > 0:
		s.pop(s.index('L'))
		s.pop(s.index('R'))
		ans += 2
	if s.count('U') > 0 and s.count('D') > 0:
		s.pop(s.index('U'))
		s.pop(s.index('D'))
		ans += 2
print(ans)


n = int(input())
a = input()
k = 0
l = 0
r = 0
u = 0
d = 0
for i in range(n):
	if a[i] == 'L':
		l += 1
	elif a[i] == 'R':
		r += 1
	elif a[i] == 'U':
		u += 1
	elif a[i] == 'D':
		d += 1
lr = min(l, r)
ud = min(u, d)
rezt = 0
if u != 0 and d != 0:
	rezt += ud * 2
if l != 0 and r != 0:
	rezt += lr * 2
print(rezt)


n = int(input())
s = input()
mp = {'U': 0, 'D': 0, 'L': 0, 'R': 0}
for c in s:
	mp[c] += 1
total = min(mp['U'], mp['D']) + min(mp['R'], mp['L'])
print(total * 2)


n = int(input())
s = input()
up = 0
rgt = 0
for x in s:
	if x == 'U':
		up += 1
	elif x == 'D':
		up -= 1
	elif x == 'R':
		rgt += 1
	else:
		rgt -= 1
print(n - abs(up) - abs(rgt))


n = int(input())
k = input()
hori = min(k.count('R'), k.count('L'))
vert = min(k.count('D'), k.count('U'))
print((hori + vert) * 2)


n = int(input())
A = {'L': 0, 'R': 0, 'D': 0, 'U': 0}
for x in input():
	A[x] += 1
print(n - abs(A['L'] - A['R']) - abs(A['D'] - A['U']))


N = int(input())
S = list(input())
(x, y) = (0, 0)
for c in S:
	if c == 'U':
		y += 1
	if c == 'D':
		y -= 1
	if c == 'L':
		x -= 1
	if c == 'R':
		x += 1
print(N - abs(x) - abs(y))


x = int(input())
y = input()
R = L = U = D = 0
for z in y:
	if z == 'R':
		R += 1
	elif z == 'L':
		L += 1
	elif z == 'U':
		U += 1
	else:
		D += 1
ans = 0
ans += min(D, U) * 2
ans += min(R, L) * 2
print(ans)


n = int(input())
a = input()
ans = 0
if a.count('L') >= a.count('R'):
	ans += a.count('R')
elif a.count('L') <= a.count('R'):
	ans += a.count('L')
if a.count('U') <= a.count('D'):
	ans += a.count('U')
elif a.count('U') >= a.count('D'):
	ans += a.count('D')
print(2 * ans)


def buggybot(n, commands):
	u = 0
	d = 0
	l = 0
	r = 0
	for i in range(n):
		if commands[i] == 'U':
			u += 1
		if commands[i] == 'D':
			d += 1
		if commands[i] == 'L':
			l += 1
		if commands[i] == 'R':
			r += 1
	v = abs(l - r)
	w = abs(u - d)
	return n - v - w
print(buggybot(int(input()), input()))


n = int(input())
s = input()
a = [0] * 4
for i in s:
	if i == 'U':
		a[0] += 1
	elif i == 'D':
		a[1] += 1
	elif i == 'L':
		a[2] += 1
	else:
		a[3] += 1
ans = 2 * min(a[0], a[1]) + 2 * min(a[2], a[3])
print(ans)


from collections import Counter
n = int(input())
s = input()
c = Counter(s)
p = c['L']
q = c['R']
r = c['U']
s = c['D']
x = min(p, q) * 2
y = min(r, s) * 2
print(x + y)


n = int(input())
s = str(input())
ans = min(s.count('U'), s.count('D'))
ans += min(s.count('L'), s.count('R'))
print(2 * ans)


n = int(input())
s = input()

def abs(x):
	if x >= 0:
		return x
	return -x
l = r = u = d = 0
for c in s:
	if c == 'U':
		u += 1
	elif c == 'D':
		d += 1
	elif c == 'L':
		l += 1
	else:
		r += 1
err1 = abs(l - r)
err2 = abs(u - d)
print(n - err1 - err2)


n = int(input())
a = [c for c in input()]
cR = sum([1 for i in a if i == 'R'])
cL = sum([1 for i in a if i == 'L'])
cU = sum([1 for i in a if i == 'U'])
cD = sum([1 for i in a if i == 'D'])
print(min(cR, cL) * 2 + min(cU, cD) * 2)


n = int(input())
x = 0
y = 0
s = input()
ans = 2 * min(s.count('L'), s.count('R')) + 2 * min(s.count('U'), s.count('D'))
print(ans)


n = int(input())
s = input()
if s.count('L') <= s.count('R'):
	if s.count('U') <= s.count('D'):
		print(s.count('L') * 2 + s.count('U') * 2)
	else:
		print(s.count('L') * 2 + s.count('D') * 2)
elif s.count('U') <= s.count('D'):
	print(s.count('R') * 2 + s.count('U') * 2)
else:
	print(s.count('R') * 2 + s.count('D') * 2)


n = int(input())
s = input()
t = [s.count('U'), s.count('D'), s.count('L'), s.count('R')]
q = min(t[0], t[1]) * 2 + min(t[2], t[3]) * 2
print(q)


n = int(input())
s = input()
U = D = L = R = 0
for let in s:
	if let == 'U':
		U += 1
	elif let == 'D':
		D += 1
	elif let == 'L':
		L += 1
	else:
		R += 1
print(min(L, R) * 2 + min(U, D) * 2)


n = int(input())
s = input()
x = 0
y = 0
ct = 0
ans = 0
for i in s:
	if i == 'L':
		x -= 1
	elif i == 'R':
		x += 1
	elif i == 'U':
		y += 1
	else:
		y -= 1
print(n - (abs(x) + abs(y)))


n = int(input())
s = list(input())

def horizontal(s):
	lcount = s.count('L')
	rcount = s.count('R')
	if lcount != 0 and rcount != 0:
		return min(lcount, rcount)
	else:
		return 0

def vertical(s):
	ucount = s.count('U')
	dcount = s.count('D')
	if ucount != 0 and dcount != 0:
		return min(ucount, dcount)
	else:
		return 0
if horizontal != 0 and vertical != 0:
	print(horizontal(s) * 2 + vertical(s) * 2)
else:
	print(0)


n = int(input().strip())
cmd = input().strip()
L = 0
R = 0
U = 0
D = 0
for c in cmd:
	if c == 'L':
		L += 1
	elif c == 'R':
		R += 1
	elif c == 'U':
		U += 1
	elif c == 'D':
		D += 1
m = abs(L - R) + abs(U - D)
print(n - m)


n = int(input())
s = input()
(h, v) = (min(s.count('L'), s.count('R')), min(s.count('U'), s.count('D')))
print(2 * h + 2 * v)


import sys
inf = float('inf')
mod = 1000000007

def get_array():
	return list(map(int, sys.stdin.readline().split()))

def get_ints():
	return map(int, sys.stdin.readline().split())

def input():
	return sys.stdin.readline()

def main():
	n = int(input())
	com = input().rstrip()
	aux = [0] * 4
	for i in com:
		if i == 'L':
			aux[0] += 1
		elif i == 'R':
			aux[1] += 1
		elif i == 'U':
			aux[2] += 1
		else:
			aux[3] += 1
	sideway = min(aux[0], aux[1]) * 2
	vertical = min(aux[2], aux[3]) * 2
	print(sideway + vertical)
main()


n = int(input())
s = input()
l = s.count('L')
d = s.count('D')
u = s.count('U')
r = s.count('R')
lr = min(l, r)
ud = min(u, d)
print(2 * (lr + ud))


input()
i = input()
C = lambda c: i.count(c)
print(min(C('U'), C('D')) * 2 + min(C('L'), C('R')) * 2)


from sys import stdin, stdout
n = int(stdin.readline().strip())
ls = stdin.readline().strip()
counts = {'L': 0, 'R': 0, 'U': 0, 'D': 0}
for i in range(n):
	counts[ls[i]] += 1
ans = 2 * (min(counts['L'], counts['R']) + min(counts['U'], counts['D']))
stdout.write('%d\n' % ans)


n = int(input())
t = input()
z = 0
d = {'L': 0, 'R': 0, 'U': 0, 'D': 0}
for i in range(n):
	d[t[i]] = d[t[i]] + 1
	if d['L'] == d['R'] and d['U'] == d['D']:
		z = max(i + 1, z)
print(n - abs(d['L'] - d['R']) - abs(d['U'] - d['D']))


def count(s):
	x = 0
	y = 0
	steps = 0
	maxCount = 0
	for c in s:
		if c == 'U':
			y += 1
		elif c == 'D':
			y -= 1
		elif c == 'L':
			x -= 1
		elif c == 'R':
			x += 1
		steps += 1
		if x == 0 and y == 0:
			maxCount = steps
	print(maxCount)

def count2(s):
	left = 0
	right = 0
	up = 0
	down = 0
	for c in s:
		if c == 'U':
			up += 1
		elif c == 'D':
			down += 1
		elif c == 'L':
			left += 1
		elif c == 'R':
			right += 1
	print(len(s) - abs(left - right) - abs(up - down))

def test():
	count2('LDUR')
	count2('RRRUU')
	count2('LLRRRR')

def nia():
	s = input()
	while len(s) == 0:
		s = input()
	s = s.split()
	iVal = []
	for i in range(len(s)):
		iVal.append(int(s[i]))
	return iVal

def solve():
	n = input()
	count2(input())
solve()


x = int(input())
st = input()
a = st.count('U')
b = st.count('D')
c = st.count('L')
d = st.count('R')
m = a - b
n = c - d
if m < 0:
	m = -m
if n < 0:
	n = -n
print(x - (m + n))


n = int(input())
command = input()
d = {}
for item in command:
	d[item] = d.get(item, 0) + 1
res = []
made = float('inf')
for item in 'UD':
	made = min(made, d.get(item, 0))
res.append(made * 2)
made = float('inf')
for item in 'RL':
	made = min(made, d.get(item, 0))
res.append(made * 2)
answer = res[0] + res[1]
print(answer)


n = input()
a = input()
x = 0
y = 0
for i in range(len(a)):
	if a[i] == 'U':
		y += 1
	elif a[i] == 'D':
		y -= 1
	elif a[i] == 'L':
		x -= 1
	elif a[i] == 'R':
		x += 1
print(len(a) - abs(x) - abs(y))


import math
import itertools
import collections

def getdict(n):
	d = {}
	if type(n) is list:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)
n = ii()
s = input()
print((min(s.count('L'), s.count('R')) + min(s.count('D'), s.count('U'))) * 2)


n = int(input())
line = input()
u = 0
d = 0
l = 0
r = 0
for c in line:
	u += c == 'U'
	l += c == 'L'
	r += c == 'R'
	d += c == 'D'
print((min(l, r) + min(d, u)) * 2)


n = int(input())
s = input()
dc = {'U': 0, 'D': 0, 'L': 0, 'R': 0}
for char in s:
	dc[char] += 1
print(min(dc['L'], dc['R']) * 2 + min(dc['U'], dc['D']) * 2)


n = int(input())
inp = lambda : map(int, input().split())
s = input()
l = len(s)
up = 0
right = 0
for i in range(l):
	if s[i] == 'U':
		up += 1
	if s[i] == 'D':
		up -= 1
	if s[i] == 'L':
		right -= 1
	if s[i] == 'R':
		right += 1
print(l - abs(up) - abs(right))


n = int(input())
s = input()
from collections import defaultdict
d = defaultdict(int)
for i in s:
	d[i] += 1
ans = 0
ans += min(d['R'], d['L'])
ans += min(d['U'], d['D'])
print(ans * 2)


def sol(v, l):
	a = 0
	b = 0
	for x in range(0, l):
		if v[x] == 'U':
			a += 1
		if v[x] == 'D':
			a -= 1
		if v[x] == 'L':
			b -= 1
		if v[x] == 'R':
			b += 1
	return abs(a) + abs(b)

def main():
	la = int(input(''))
	n = input('')
	print(la - sol(n, la))
main()


input()
x = {'U': 0, 'D': 0, 'R': 0, 'L': 0}
for i in input():
	x[i] += 1
print(min(x['U'], x['D']) * 2 + min(x['R'], x['L']) * 2)


n = int(input())
c = input()
(x, y) = (0, 0)
x += c.count('R')
x -= c.count('L')
y += c.count('U')
y -= c.count('D')
print(n - abs(x) - abs(y))


def main():
	(_, d) = (input(), {'L': 0, 'D': 0, 'U': 0, 'R': 0})
	for c in input():
		d[c] += 1
	print((min(d['L'], d['R']) + min(d['U'], d['D'])) * 2)
main()


n = int(input())
inpt = input()
L = inpt.count('L')
R = inpt.count('R')
U = inpt.count('U')
D = inpt.count('D')
count = 0
count += 2 * min(L, R) + 2 * min(U, D)
print(count)


n = int(input())
a = input().upper()
if a.count('U') == a.count('D'):
	s1 = a.count('U') * 2
else:
	s1 = min(a.count('U'), a.count('D')) * (a.count('U') != 0 and a.count('D') != 0) * 2
if a.count('L') == a.count('R'):
	s2 = a.count('R') * 2
else:
	s2 = min(a.count('L'), a.count('R')) * (a.count('R') != 0 and a.count('L') != 0) * 2
print(s1 + s2)


Input = lambda : map(int, input().split())
n = int(input())
s = input()
print(n - (abs(s.count('L') - s.count('R')) + abs(s.count('D') - s.count('U'))))


n = int(input())
moves = input()
x = 0
y = 0
i = 0
right = 0
left = 0
down = 0
up = 0
while i <= n - 1:
	if moves[i] == 'U':
		up += 1
	elif moves[i] == 'D':
		down += 1
	elif moves[i] == 'L':
		left += 1
	elif moves[i] == 'R':
		right += 1
	i += 1
hasel = 0
hasel2 = 0
if right >= left:
	hasel = left
else:
	hasel = right
if down >= up:
	hasel2 = up
else:
	hasel2 = down
print(2 * hasel + 2 * hasel2)


n = int(input())
s = input()
from collections import Counter
d = Counter(s)
ans = 2 * min(d['U'], d['D']) + 2 * min(d['R'], d['L'])
print(ans)


n = int(input())
a = list(input())
x1 = a.count('L')
x2 = a.count('D')
x3 = a.count('U')
x4 = a.count('R')
print(2 * min(x4, x1) + 2 * min(x2, x3))


import sys
n = int(input())
s = input()
i = y = 0
jav = l = r = u = d = 0
for c in s:
	jav += 1
	if c == 'L':
		l += 1
	elif c == 'R':
		r += 1
	elif c == 'U':
		u += 1
	elif c == 'D':
		d += 1
print(2 * (min(l, r) + min(u, d)))


n = int(input())
s = input()
V = ['U', 'D', 'L', 'R']
C = [0, 0, 0, 0]
for l in s:
	C[V.index(l)] += 1
print(2 * min(C[0], C[1]) + 2 * min(C[2], C[3]))


n = int(input())
s = input().strip()
(x, y) = (0, 0)
count = 0
for e in s:
	count += 1
	if e == 'L':
		x -= 1
	if e == 'R':
		x += 1
	if e == 'U':
		y += 1
	if e == 'D':
		y -= 1
print(count - abs(x) - abs(y))


n = int(input())
a = input()
link = [0] * 4
for i in range(n):
	if a[i] == 'R':
		link[0] += 1
	elif a[i] == 'L':
		link[1] += 1
	elif a[i] == 'U':
		link[2] += 1
	elif a[i] == 'D':
		link[3] += 1
counter = (min(link[0], link[1]) + min(link[2], link[3])) * 2
print(counter)


import sys
n = int(input())
command = input()
counts = {'L': 0, 'R': 0, 'U': 0, 'D': 0}
for i in command:
	counts[i] += 1
print(2 * min(counts['L'], counts['R']) + 2 * min(counts['U'], counts['D']))


I = lambda : map(int, input().split())
n = int(input())
s = input()
f = -1
l = [0, 0]
for i in range(n):
	if s[i] == 'L':
		l[0] -= 1
	elif s[i] == 'U':
		l[1] += 1
	elif s[i] == 'D':
		l[1] -= 1
	else:
		l[0] += 1
print(max(0, n - (abs(l[0]) + abs(l[1]))))


n = int(input())
c = input()
(x, y) = (0, 0)
c_l = 0
c_r = 0
c_u = 0
c_d = 0
for i in range(len(c)):
	if c[i] == 'R':
		c_r += 1
	if c[i] == 'L':
		c_l += 1
	if c[i] == 'U':
		c_u += 1
	if c[i] == 'D':
		c_d += 1
print(min(c_r, c_l) * 2 + min(c_u, c_d) * 2)


n = int(input())
a = input()
ans = 0
x = [0 for i in range(n + 1)]
y = [0 for j in range(n + 1)]
pos = [[0, 0, 0, 0] for i in range(n + 1)]
for i in range(0, n):
	if a[i] == 'L':
		pos[i + 1] = [pos[i][0] + 1, pos[i][1], pos[i][2], pos[i][3]]
	if a[i] == 'U':
		pos[i + 1] = [pos[i][0], pos[i][1], pos[i][2] + 1, pos[i][3]]
	if a[i] == 'D':
		pos[i + 1] = [pos[i][0], pos[i][1], pos[i][2], pos[i][3] + 1]
	if a[i] == 'R':
		pos[i + 1] = [pos[i][0], pos[i][1] + 1, pos[i][2], pos[i][3]]
for i in range(1, n + 1):
	ans = max(ans, 2 * min(pos[i][0], pos[i][1]) + 2 * min(pos[i][2], pos[i][3]))
print(ans)


n = int(input())
seq = input()
x_axis = [seq.count('U'), seq.count('D')]
y_axis = [seq.count('L'), seq.count('R')]
print(min(x_axis) * 2 + min(y_axis) * 2)


n = int(input())
arr = list(input())
m = 0
x = 0
y = 0
count = 0
temp = 0
for i in range(len(arr)):
	if arr[i] == 'U':
		y += 1
	elif arr[i] == 'D':
		y -= 1
	elif arr[i] == 'L':
		x -= 1
	elif arr[i] == 'R':
		x += 1
print(n - (abs(x) + abs(y)))


n = int(input())
ent = input()
Horiz = 0
Vert = 0
for i in range(n):
	if ent[i] == 'R':
		Horiz += 1
	elif ent[i] == 'L':
		Horiz -= 1
	elif ent[i] == 'U':
		Vert += 1
	else:
		Vert -= 1
com = n - abs(Horiz) - abs(Vert)
print(com)


from collections import Counter
n = int(input())
s = input().strip()
z = Counter(s)
print(2 * min(z['L'], z['R']) + 2 * min(z['U'], z['D']))


n = int(input())
s = input()
l_count = 0
r_count = 0
u_count = 0
d_count = 0
for i in s:
	if i == 'L':
		l_count += 1
	elif i == 'R':
		r_count += 1
	elif i == 'U':
		u_count += 1
	else:
		d_count += 1
count = 0
count += abs(l_count - r_count)
count += abs(u_count - d_count)
print(n - count)


num = input()
sequence = input()
right = 0
left = 0
up = 0
down = 0
for i in sequence:
	if i == 'R':
		right += 1
	if i == 'L':
		left += 1
	if i == 'U':
		up += 1
	if i == 'D':
		down += 1
print((min(left, right) + min(up, down)) * 2)


count = {'U': 0, 'D': 0, 'L': 0, 'R': 0}
n = int(input())
s = list(input())
for i in s:
	count[i] += 1
print(2 * min(count['U'], count['D']) + 2 * min(count['L'], count['R']))


def main(n, a):
	x = 0
	y = 0
	for i in range(n):
		if a[i] == 'L':
			x -= 1
		elif a[i] == 'R':
			x += 1
		elif a[i] == 'U':
			y += 1
		elif a[i] == 'D':
			y -= 1
	return n - abs(x) - abs(y)
print(main(int(input()), list(input())))


n = int(input())
string = input()
A = list()
for i in string:
	A.append(i)
ans = 0
for i in range(len(A)):
	if A.count('U') > 0 and A.count('D') > 0:
		A.remove('U')
		A.remove('D')
		ans += 2
	if A.count('R') > 0 and A.count('L') > 0:
		A.remove('R')
		A.remove('L')
		ans += 2
print(ans)


n = int(input())
s = input()
d = {}
ans = 0
for i in range(n):
	if s[i] in d:
		d[s[i]] += 1
	else:
		d[s[i]] = 1
if 'U' in d and 'D' in d:
	ans += min(d['U'], d['D'])
if 'R' in d and 'L' in d:
	ans += min(d['R'], d['L'])
print(ans * 2)


n = int(input())
s = input()
l = s.count('L')
r = s.count('R')
u = s.count('U')
d = s.count('D')
l_r = min(l, r)
u_d = min(u, d)
print(2 * l_r + 2 * u_d)


n = int(input())
st = str(input())
(l, r, u, d) = (st.count('L'), st.count('R'), st.count('U'), st.count('D'))
ans = 0
if l > 0 and r > 0:
	if l > r:
		ans += r * 2
	else:
		ans += l * 2
if u > 0 and d > 0:
	if u > d:
		ans += d * 2
	else:
		ans += u * 2
print(ans)


(N, Commands) = (int(input()), list(input()))
print(2 * (min(Commands.count('L'), Commands.count('R')) + min(Commands.count('U'), Commands.count('D'))))


n = int(input())
s = str(input())
(u, d, l, r) = (0, 0, 0, 0)
for i in range(n):
	if s[i] == 'U':
		u += 1
	elif s[i] == 'D':
		d += 1
	elif s[i] == 'L':
		l += 1
	else:
		r += 1
ans = min(u, d) * 2 + min(l, r) * 2
print(ans)


from collections import Counter

def main():
	n = int(input())
	s = input()
	c = Counter(s)
	ans = min(c['L'], c['R']) + min(c['U'], c['D'])
	print(2 * ans)
main()


n = int(input())
commands = input()
left = 0
right = 0
up = 0
down = 0
for i in commands:
	if i == 'U':
		up += 1
	elif i == 'D':
		down += 1
	elif i == 'R':
		right += 1
	elif i == 'L':
		left += 1
	else:
		raise ValueError
print(2 * min(right, left) + 2 * min(up, down))


n = int(input())
a = list(input())
(x, y) = (0, 0)
for i in a:
	if i == 'U':
		y += 1
	elif i == 'D':
		y -= 1
	elif i == 'L':
		x -= 1
	else:
		x += 1
print(n - abs(x) - abs(y))


n = int(input())
a = input()
uc = a.count('U')
dc = a.count('D')
lc = a.count('L')
rc = a.count('R')
print(min(dc, uc) * 2 + min(lc, rc) * 2)


n = int(input())
s = list(input())
l = 0
r = 0
u = 0
d = 0
for i in s:
	if i == 'L':
		l += 1
	if i == 'U':
		u += 1
	if i == 'R':
		r += 1
	if i == 'D':
		d += 1
m1 = min(l, r) * 2
m2 = min(u, d) * 2
if l > 0 and r > 0 or (l == 0 and r == 0):
	print(m1 + m2)
elif u > 0 and d > 0 or (u == 0 and d == 0):
	print(m1 + m2)
else:
	print('0')


U = L = R = D = ans = 0
n = int(input())
s = str(input())
for i in range(len(s)):
	if s[i] == 'L':
		L += 1
	elif s[i] == 'R':
		R += 1
	elif s[i] == 'U':
		U += 1
	else:
		D += 1
ans += min(L, R) * 2
ans += min(U, D) * 2
print(ans)


n = map(int, input())
cm = input()
U = cm.count('U')
D = cm.count('D')
L = cm.count('L')
R = cm.count('R')
print(len(cm) - abs(U - D) - abs(L - R))


n = int(input())
commands = list(input())
R_counter = 0
L_counter = 0
U_counter = 0
D_counter = 0
final = 0
if 'R' in commands:
	R_counter = commands.count('R')
if 'L' in commands:
	L_counter = commands.count('L')
if 'U' in commands:
	U_counter = commands.count('U')
if 'D' in commands:
	D_counter = commands.count('D')
if R_counter > L_counter:
	final += R_counter - L_counter
else:
	final += L_counter - R_counter
if U_counter > D_counter:
	final += U_counter - D_counter
else:
	final += D_counter - U_counter
print(n - final)


n = int(input())
string = input()
paris = {'L': 0, 'R': 0, 'U': 0, 'D': 0}
for i in string:
	paris[i] = paris.get(i, 0) + 1
lr = min(paris['R'], paris['L']) * 2
ud = min(paris['U'], paris['D']) * 2
print(lr + ud)


input()
commands = input()
min_updown = min(commands.count('U'), commands.count('D'))
min_leftright = min(commands.count('L'), commands.count('R'))
print(2 * min_updown + 2 * min_leftright)


n = int(input())
x = input()
nx = 0
ny = 0
for i in range(len(x)):
	if x[i] == 'R':
		nx += 1
	elif x[i] == 'L':
		nx += -1
	elif x[i] == 'U':
		ny += -1
	elif x[i] == 'D':
		ny += 1
ny = abs(ny)
nx = abs(nx)
print(n - nx - ny)


n = int(input())
a = {'L': 0, 'R': 0, 'U': 0, 'D': 0}
s = list(input())
cnt = n
for i in s:
	a[i] += 1
now_cc = [0, 0]
now_cc[0] += a['U']
now_cc[0] -= a['D']
now_cc[1] += a['R']
now_cc[1] -= a['L']
print(n - abs(now_cc[0]) - abs(now_cc[1]))


n = int(input())
s = input()
l = s.count('L')
r = s.count('R')
u = s.count('U')
d = s.count('D')
ans = n - (abs(l - r) + abs(u - d))
print(ans)


a = b = c = d = 0
n = int(input())
direction = input()
for dir in direction:
	if dir == 'U':
		a += 1
	elif dir == 'D':
		b += 1
	elif dir == 'L':
		c += 1
	elif dir == 'R':
		d += 1
print(min(a, b) * 2 + min(c, d) * 2)


def buggyRobot():
	xcor = 0
	ycor = 0
	numMoves = input()
	dirSeq = input()
	for direct in dirSeq:
		if direct == 'U':
			ycor += 1
		elif direct == 'D':
			ycor -= 1
		elif direct == 'L':
			xcor -= 1
		else:
			xcor += 1
	print(int(numMoves) - abs(xcor) - abs(ycor))
buggyRobot()


first_line = input()
commands = input()
n = int(first_line)
x_left = 0
x_right = 0
y_up = 0
y_down = 0
for i in range(n):
	if commands[i] == 'L':
		x_left += 1
	elif commands[i] == 'R':
		x_right += 1
	elif commands[i] == 'U':
		y_up += 1
	elif commands[i] == 'D':
		y_down += 1
x = 0
y = 0
if x_left < x_right:
	x = x_left * 2
elif x_left > x_right:
	x = x_right * 2
else:
	x = x_left + x_right
if y_down < y_up:
	y = y_down * 2
elif y_down > y_up:
	y = y_up * 2
else:
	y = y_down + y_up
print(x + y)


import collections
n = int(input())
s = input()
ctr = collections.Counter(s)
cnt = 0
if 'R' in ctr and 'L' in ctr:
	cnt += min(ctr['R'], ctr['L']) * 2
if 'U' in ctr and 'D' in ctr:
	cnt += min(ctr['U'], ctr['D']) * 2
print(cnt)


n = int(input())
sequence = input()
numOfU = sequence.count('U')
numOfD = sequence.count('D')
numOfL = sequence.count('L')
numOfR = sequence.count('R')
print(2 * (min(numOfL, numOfR) + min(numOfU, numOfD)))


n = int(input())
a = input()
c = 0
x = 0
y = 0
t = 0
for t in range(len(a)):
	i = a[t]
	if i == 'U':
		y += 1
	elif i == 'D':
		y -= 1
	elif i == 'R':
		x += 1
	else:
		x -= 1
	if x == 0 and y == 0:
		c = t + 1
print(n - (abs(x) + abs(y)))


n = int(input())
line = input()
l = 0
r = 0
u = 0
d = 0
for elem in line:
	if elem == 'L':
		l += 1
	if elem == 'R':
		r += 1
	if elem == 'U':
		u += 1
	if elem == 'D':
		d += 1
print(min(l, r) * 2 + min(u, d) * 2)


n = int(input())
arr = input()
x1 = x2 = y1 = y2 = 0
res = 0
for i in range(0, n):
	if arr[i] == 'L':
		x1 += 1
	if arr[i] == 'R':
		x2 += 1
	if arr[i] == 'D':
		y1 += 1
	if arr[i] == 'U':
		y2 += 1
if x1 > x2:
	res += x2
else:
	res += x1
if y1 > y2:
	res += y2
else:
	res += y1
print(res * 2)


import sys
import math
import operator as op
from functools import reduce
from sys import maxsize

def read_line():
	return sys.stdin.readline()[:-1]

def read_int():
	return int(sys.stdin.readline())

def read_int_line():
	return [int(v) for v in sys.stdin.readline().split()]

def read_float_line():
	return [float(v) for v in sys.stdin.readline().split()]

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer / denom

def nc2(n):
	return n * (n - 1) // 2
t = 1
for i in range(t):
	n = read_int()
	s = read_line()
	d = {}
	for i in s:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	ans = 0
	l = 'L'
	r = 'R'
	try:
		lc = d[l]
		rc = d[r]
	except:
		lc = 0
		rc = 0
	diff1 = 2 * min(lc, rc)
	u = 'U'
	do = 'D'
	try:
		uc = d[u]
		dc = d[do]
	except:
		uc = 0
		dc = 0
	diff2 = 2 * min(uc, dc)
	ans = diff1 + diff2
	print(ans)


n = int(input())
ch = input()
L = [0, 0]
for i in ch:
	if i == 'L':
		L[0] -= 1
	if i == 'R':
		L[0] += 1
	if i == 'U':
		L[1] += 1
	if i == 'D':
		L[1] -= 1
print(len(ch) - abs(L[0]) - abs(L[1]))


n = int(input())
com = input()
print(min(com.count('L'), com.count('R')) * 2 + min(com.count('U'), com.count('D')) * 2)