Little Chris knows there's no fun in playing dominoes, he thinks it's too random and doesn't require skill. Instead, he decided to play with the dominoes and make a "domino show".

Chris arranges n dominoes in a line, placing each piece vertically upright. In the beginning, he simultaneously pushes some of the dominoes either to the left or to the right. However, somewhere between every two dominoes pushed in the same direction there is at least one domino pushed in the opposite direction.

After each second, each domino that is falling to the left pushes the adjacent domino on the left. Similarly, the dominoes falling to the right push their adjacent dominoes standing on the right. When a vertical domino has dominoes falling on it from both sides, it stays still due to the balance of the forces. The figure shows one possible example of the process. [Image] 

Given the initial directions Chris has pushed the dominoes, find the number of the dominoes left standing vertically at the end of the process!


-----Input-----

The first line contains a single integer n (1 ≤ n ≤ 3000), the number of the dominoes in the line. The next line contains a character string s of length n. The i-th character of the string s_{i} is equal to   "L", if the i-th domino has been pushed to the left;  "R", if the i-th domino has been pushed to the right;  ".", if the i-th domino has not been pushed. 

It is guaranteed that if s_{i} = s_{j} = "L" and i < j, then there exists such k that i < k < j and s_{k} = "R"; if s_{i} = s_{j} = "R" and i < j, then there exists such k that i < k < j and s_{k} = "L".


-----Output-----

Output a single integer, the number of the dominoes that remain vertical at the end of the process.


-----Examples-----
Input
14
.L.R...LR..L..

Output
4

Input
5
R....

Output
0

Input
1
.

Output
1



-----Note-----

The first example case is shown on the figure. The four pieces that remain standing vertically are highlighted with orange.

In the second example case, all pieces fall down since the first piece topples all the other pieces.

In the last example case, a single piece has not been pushed in either direction.

Source: codeforces | Difficulty: EASY


Solutions:
n = int(input())
s = input()
last = ''
lasti = -1
count = 0
for (i, v) in enumerate(s):
	if v == 'R' and lasti == -1:
		count += i
		last = 'R'
		lasti = i
	elif v == 'L' and lasti == -1:
		last = 'L'
		lasti = i
	elif last == 'L' and v == 'R':
		count += i - lasti - 1
		last = 'R'
		lasti = i
	elif last == 'R' and v == 'L':
		count += 0 if (i + lasti) % 2 > 0 else 1
		last = 'L'
		lasti = i
if last == 'L':
	count += n - 1 - lasti
if lasti == -1:
	count = n
print(count)


n = int(input())
s = list(input()) + ['R']
prev = 'L'
c = ans = 0
for i in range(n + 1):
	if prev == 'L' and s[i] == 'R':
		ans += c
	elif prev == 'R' and s[i] == 'L' and (c % 2 != 0):
		ans += 1
	if s[i] != '.':
		prev = s[i]
		c = 0
	else:
		c += 1
print(ans)


n = input()
s = str(input())
ans = 0
tmp = 0
foundedRight = False
for i in range(len(s)):
	if not foundedRight:
		if s[i] == '.':
			tmp = tmp + 1
		elif s[i] == 'L':
			tmp = 0
		elif s[i] == 'R':
			ans = ans + tmp
			tmp = 0
			foundedRight = True
	elif s[i] == '.':
		tmp = tmp + 1
	elif s[i] == 'R':
		tmp = 0
	elif s[i] == 'L':
		foundedRight = False
		if tmp % 2 == 1:
			ans = ans + 1
		tmp = 0
if not foundedRight:
	ans = ans + tmp
print(ans)


n = int(input())
s = input()
r = [0] * n
l = [0] * n
index = -1
for i in range(0, n):
	if s[i] == '.':
		r[i] = index
	elif s[i] == 'R':
		index = i
		r[i] = 0
	elif s[i] == 'L':
		r[i] = -1
		index = -1
index = -1
result = 0
for i in range(n - 1, -1, -1):
	if s[i] == '.':
		l[i] = index
	elif s[i] == 'L':
		index = i
		l[i] = 0
	elif s[i] == 'R':
		l[i] = -1
		index = -1
	if l[i] < 0 and r[i] < 0 or (l[i] >= 0 and r[i] >= 0 and (l[i] - i == i - r[i])):
		result += 1
print(result)


input()
res = r = 0
for (i, x) in enumerate(input(), 1):
	if x == 'R':
		r = i
	elif x == 'L':
		if r:
			res += r + i - 1 & 1
		else:
			res = 0
		r = 0
	elif not r:
		res += 1
print(res)


n = int(input())
dominoes = input()
state = 'L'
count = 0
ans = 0
for x in range(n):
	if dominoes[x] == '.':
		count += 1
	if dominoes[x] == 'L':
		if state == 'R':
			if count % 2 == 1:
				ans += 1
		count = 0
		state = 'L'
	if dominoes[x] == 'R':
		if state == 'L':
			ans += count
		count = 0
		state = 'R'
if state == 'L':
	ans += count
print(ans)


from collections import deque
count = int(input())
dominoes = input()
standing = 0
falling = False
diff = 0
for c in dominoes:
	if c == '.' and (not falling):
		standing += 1
	elif c == '.' and falling:
		diff += 1
	elif c == 'L' and (not falling):
		standing = 0
	elif c == 'L' and falling:
		standing += diff % 2
		diff = 0
		falling = False
	elif c == 'R':
		falling = True
		standing += diff
		diff = 0
print(standing)


n = int(input())
s = input()
r = -1
l = n - 1
l1 = 0
n1 = n
for i in range(n):
	if s[i] == 'L':
		if r == -1:
			n1 -= i - l1 + 1
			l1 = i + 1
		else:
			n1 -= i - l1 + 1
			l1 = i + 1
			if (r - i) % 2 == 0:
				n1 += 1
		r = -1
	if s[i] == 'R':
		r = i
		l1 = i
if r != -1:
	n1 -= n - r
print(n1)


n = int(input())
a = input().strip()
nextl = [-1] * n
lastr = [-1] * n
ll = -1
for i in range(n):
	if a[i] == 'R':
		ll = i
	if a[i] == 'L':
		ll = -1
	lastr[i] = ll
nl = -1
for i in range(n - 1, -1, -1):
	if a[i] == 'L':
		nl = i
	if a[i] == 'R':
		nl = -1
	nextl[i] = nl
ans = 0
for i in range(n):
	if nextl[i] == lastr[i] == -1:
		ans += 1
	if nextl[i] == -1 or lastr[i] == -1:
		continue
	d1 = nextl[i] - i
	d2 = i - lastr[i]
	if d1 == d2:
		ans += 1
print(ans)


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))

def input():
	return sys.stdin.readline().rstrip('\r\n')
n = int(input())
s = input()
count = 0
dot = 0
lastoccur = '.'
for i in range(0, len(s)):
	if s[i] == '.':
		dot += 1
	elif s[i] == 'R':
		if lastoccur == 'L':
			count += dot
			dot = 0
			lastoccur = 'R'
		elif lastoccur == '.':
			count += dot
			dot = 0
			lastoccur = 'R'
		else:
			dot = 0
	elif lastoccur == 'L':
		dot = 0
	elif lastoccur == 'R':
		if dot % 2 == 0:
			dot = 0
			lastoccur = 'L'
		else:
			count += 1
			dot = 0
			lastoccur = 'L'
	else:
		lastoccur = 'L'
		dot = 0
if dot > 0 and lastoccur != 'R':
	count += dot
print(count)


n = int(input())
s = list(input())
count = 0
(l, r) = (-1, 0)
while True:
	if l == -1:
		if 'R' in s:
			r = s.index('R')
			if 'L' in s[:r]:
				l = s.index('L')
				count += r - l - 1
			else:
				count += r
			l = r
		elif 'L' in s:
			count = n - s.index('L') - 1
			break
		else:
			count = n
			break
	elif s[l] == 'R':
		if 'L' in s[l:]:
			r += s[l:].index('L')
			if r - l - 1 & 1:
				count += 1
			l = r
		else:
			break
	elif 'R' in s[l:]:
		r += s[l:].index('R')
		count += r - l - 1
		l = r
	else:
		count += n - l - 1
		break
print(count)


a = []
n = int(input())
a = input().strip()
cnt = 0
l = -1
r = -1
for i in range(n):
	if a[i] == '.':
		if l == -1 and r == -1:
			cnt += 1
	if a[i] == 'L':
		if r != -1:
			l = i
			cnt += (l - r + 1) % 2
		else:
			cnt -= i
			l = i
	if a[i] == 'R':
		if l != -1:
			r = i
			cnt += r - l - 1
		else:
			r = i
if l > r:
	cnt += n - l - 1
print(cnt)


import sys
n = int(input())
s = str(input())
ans = num = 0
l = r = False
k = 0
j = 0
while j < n:
	if s[j] == 'R' or s[j] == 'L':
		break
	else:
		j += 1
if j == n:
	print(n)
	sys.exit()
for i in range(n):
	if s[i] == '.' and l is False:
		num += 1
	if s[i] == 'L' and r is False:
		num = 0
		l = True
	if s[i] == '.' and l is True:
		ans += 1
	if s[i] == 'R' and l is True:
		k = i
		l = False
		r = True
	if s[i] == 'R' and l is False:
		ans += num
		num = 0
		r = True
	if s[i] == 'L' and r is True:
		if num % 2 == 1:
			ans += 1
		num = 0
		l = True
		f = False
print(ans)


import re
input()
ds = 'L' + input() + 'R'
res = len(re.findall('R(?:\\.\\.)*\\.L', ds)) + sum([len(s) - 2 for s in re.findall('L\\.*R', ds)])
print(res)


n = int(input())
s = input()
c = 0
(m, l, r) = (0, -1, -1)
for i in range(n):
	if c == 0:
		if s[i] == 'R':
			m += i
			c = 1
			r = i
		elif s[i] == 'L':
			c = 1
			l = i
	elif r > -1 and s[i] == 'L':
		if (i - r) % 2 == 0:
			m += 1
		r = -1
		l = i
	elif l > -1 and s[i] == 'R':
		m += i - l - 1
		l = -1
		r = i
if l > -1:
	m += len(s) - l - 1
if s.count('.') == n:
	print(n)
else:
	print(m)


N = int(input())
S = input()
A = [1 for i in range(N)]
mode = -1
ans = 0
for i in range(N):
	c = S[i]
	if c == 'L':
		if mode == -1:
			for k in range(i + 1):
				A[k] = 0
		else:
			if (i - mode + 1) % 2 == 1:
				ans += 1
			for k in range(mode, i + 1):
				A[k] = 0
			mode = -1
	elif c == 'R':
		mode = i
if mode != -1:
	for k in range(mode, N):
		A[k] = 0
for i in range(N):
	ans += A[i]
print(ans)


n = int(input())
x = input()
i = 0
c = 0
while i < n:
	if x[i] == 'L' or x[i] == 'R':
		if x[i] == 'R':
			c += i
		break
	i += 1
if i == n:
	for i in range(n):
		if x[i] == 'R':
			break
	print(i + 1)
else:
	j = i + 1
	while j < n:
		if x[j] == '.':
			j += 1
		elif x[i] == '.':
			i += 1
			continue
		elif x[i] == 'R' and x[j] == 'L':
			if (j - i - 1) % 2 == 1:
				c += 1
			i = j
			j += 1
		elif x[i] == 'L' and x[j] == 'R':
			c += j - i - 1
			i = j
			j += 1
	if x[i] == 'L' and x[-1] == '.':
		c += j - i - 1
	print(c)


import sys
n = int(input())
s = input()
a = []
for i in range(n):
	if s[i] == 'L':
		a.append(['L', i])
	if s[i] == 'R':
		a.append(['R', i])
i = 0
j = len(a) - 1
if len(a) == 0:
	print(n)
	return
if a[0][0] == 'L':
	A = a[0][1]
	i = 1
else:
	A = -1
if a[len(a) - 1][0] == 'R':
	j = len(a) - 2
	D = a[-1][1]
else:
	D = n
ans = 0
if i > j:
	B = 1
	C = 0
else:
	B = a[i][1]
	C = a[j][1]
while i < j:
	if (a[i][1] - a[i + 1][1]) % 2 == 0:
		ans += 1
	if i != j - 1:
		ans += a[i + 2][1] - a[i + 1][1] - 1
	i += 2
if B > C:
	ans += D - A - 1
else:
	ans += B - A - 1 + D - C - 1
print(ans)


n = int(input())
s = input()
(t, res, prev) = (0, 0, -1)
for i in range(n):
	if s[i] == 'R':
		res += i - prev - 1
		prev = i
		t = 1
	if s[i] == 'L':
		if prev != -1:
			res += (i - prev - 1) % 2
		prev = i
		t = 0
if t == 0:
	res += n - prev - 1
print(res)


import sys
inputs = sys.stdin.read().split('\n')
numCards = int(inputs[0])
assert numCards == len(inputs[1])
initialPushes = ['L']
segmentedCards = []
numOfCardsInCurrentSeg = 0
for push in inputs[1]:
	if push == 'L':
		initialPushes.append('L')
		segmentedCards.append(numOfCardsInCurrentSeg)
		numOfCardsInCurrentSeg = 0
	elif push == 'R':
		initialPushes.append('R')
		segmentedCards.append(numOfCardsInCurrentSeg)
		numOfCardsInCurrentSeg = 0
	else:
		numOfCardsInCurrentSeg += 1
initialPushes.append('R')
segmentedCards.append(numOfCardsInCurrentSeg)
numOfCardsInCurrentSeg = 0
assert len(initialPushes) == len(segmentedCards) + 1
result = 0
for idx in range(len(initialPushes) - 1):
	leftForce = initialPushes[idx]
	rightForce = initialPushes[idx + 1]
	if leftForce == 'R' and rightForce == 'L' and (segmentedCards[idx] % 2 == 1):
		result += 1
	elif leftForce == 'L' and rightForce == 'R':
		result += segmentedCards[idx]
print(result)


n = int(input())
s = input()
cnt = 0
num = 0
chk = False
for i in range(n):
	if chk and s[i] == 'L':
		if cnt % 2 == 1:
			num += 1
		chk = False
		continue
	if s[i] == 'R':
		chk = True
		cnt = 0
		continue
	if chk:
		cnt += 1
		continue
	if s[i] == 'L':
		num = 0
	else:
		num += 1
print(num)


n = int(input())
string = input()
result = 0
if set(string) == {'.'}:
	print(n)
else:
	i = 0
	met_1 = False
	met_2 = False
	start = 0
	end = n - 1
	on = True
	while i < n and (not (met_1 and met_2)):
		if string[i] != '.' and (not met_1):
			if string[i] == 'R':
				result += i
			start = i
			met_1 = True
		if string[n - 1 - i] != '.' and (not met_2):
			if string[n - 1 - i] == 'L':
				result += i
			end = n - i - 1
			met_2 = True
		i += 1
	if len(set(string)) == 2:
		print(result)
	else:
		prev = start
		i = start + 1
		while start < i <= end:
			if string[prev] == 'R' and string[i] == 'L':
				if (i - prev - 1) % 2 == 1:
					result += 1
				prev = i
			elif string[prev] == 'L' and string[i] == 'R':
				result += i - prev - 1
				prev = i
			i += 1
		print(result)


n = int(input())
s = str(input())
i = 0
while i < n and s[i] == '.':
	i += 1
ans = i
if i < n and s[i] == 'L':
	ans = 0
	i += 1
	while i < n and s[i] == '.':
		ans += 1
		i += 1
while i < n:
	j = i + 1
	while j < n and s[j] == '.':
		j += 1
	if j < n:
		if (j - i + 1) % 2 == 1:
			ans += 1
	i = j + 1
	while i < n and s[i] == '.':
		ans += 1
		i += 1
print(ans)


quantity = int(input())
while quantity < 1 or quantity > 3000:
	quantity = int(input())
directions = input()
while len(directions) != quantity:
	directions = input()
mode = '.'
count = 0
i = 0
for domino_num in range(0, quantity):
	if mode == '.' and directions[domino_num] == '.' and (domino_num < quantity - 1):
		i += 1
		mode = '.'
	elif mode == '.' and directions[domino_num] == 'L' and (domino_num < quantity - 1):
		i = 0
		mode = 'L'
	elif mode == 'L' and directions[domino_num] == '.' and (domino_num < quantity - 1):
		i += 1
		mode = '.'
	elif mode == '.' and directions[domino_num] == 'R' and (domino_num < quantity - 1):
		count += i
		i = 0
		mode = 'R'
	elif mode == 'L' and directions[domino_num] == 'R' and (domino_num < quantity - 1):
		i = 0
		mode = 'R'
	elif mode == 'R' and directions[domino_num] == '.' and (domino_num < quantity - 1):
		i += 1
		mode = 'R'
	elif mode == 'R' and directions[domino_num] == 'L':
		count += i % 2
		mode = 'L'
		i = 0
	elif mode == 'R' and domino_num == quantity - 1:
		count = count
	elif mode == '.' and directions[domino_num] == 'R' and (domino_num == quantity - 1):
		count += i
	elif mode == '.' and directions[domino_num] == '.' and (domino_num == quantity - 1):
		i += 1
		count += i
	elif mode == 'L' and directions[domino_num] == '.' and (domino_num == quantity - 1):
		i += 1
		count += i
print(count)


class Stack:

	def __init__(self):
		self.stack = []
		self.len = 0

	def top(self):
		assert not self.empty()
		return self.stack[self.len - 1]

	def pop(self):
		assert not self.empty()
		self.len -= 1
		return self.stack.pop()

	def push(self, x):
		self.len += 1
		self.stack.append(x)

	def empty(self):
		return self.len == 0

def calc(n, pos):
	st = Stack()
	last_pos = -1
	ans = 0
	for i in range(n):
		if pos[i] == 'R':
			if st.empty():
				ans += i - last_pos - 1
			st.push(i)
		elif pos[i] == 'L':
			if st.empty():
				last_pos = i
			else:
				left_R = st.pop()
				ans += (i - left_R + 1) % 2
				last_pos = i
	if st.empty():
		ans += n - last_pos - 1
	return ans
n = int(input())
pos = str(input())
print(calc(n, pos))


n = int(input())
s = input()
balance = 0
i = 0
calc = [1] * n
(firstr, lastl) = (-1, -1)
while i < n:
	if s[i] == 'R':
		balance += 1
		if firstr == -1:
			firstr = i
		i += 1
	elif s[i] == 'L':
		balance -= 1
		lastl = i
		i += 1
	else:
		i += 1
		continue
	if balance == 0:
		if (firstr - lastl) % 2 == 0:
			for j in range(firstr, lastl + 1):
				calc[j] = 0
			calc[(firstr + lastl) // 2] = 1
		else:
			for j in range(firstr, lastl + 1):
				calc[j] = 0
		firstr = -1
		lastl = -1
	elif balance == -1:
		calc = [0] * i + calc[i:]
		balance = 0
if balance != 0:
	calc = calc[:firstr] + [0] * (n - firstr)
print(sum(calc))


n = int(input())
s = input() + 'R'
r = 0
flag = 'L'
a = 0
for _ in range(n + 1):
	if s[_] == '.':
		a += 1
	elif s[_] == 'L':
		if flag == 'L':
			a = 0
		else:
			if a % 2 == 1:
				r += 1
			a = 0
			flag = 'L'
	elif flag == 'L':
		r += a
		a = 0
		flag = 'R'
	else:
		a = 0
print(r)


n = int(input())
s = input()
c = k = l = r = 0
for i in range(n):
	if s[i] == '.':
		if k == 0:
			c += 1
	else:
		if s[i] == 'L':
			k -= 1
			l = i
		else:
			k += 1
			r = i
		if k < 0:
			k = c = 0
		elif k == 0:
			c += (l - r + 1) % 2
print(c)


def main():
	n = int(input())
	s = 'L' + input()
	s += 'R'
	curr = ('L', 0)
	res = 0
	i = 0
	while i < len(s):
		if curr[0] == 'L':
			if s[i] == 'L':
				curr = ('L', i)
			elif s[i] == 'R':
				res += i - curr[1] - 1
				curr = ('R', i)
		elif curr[0] == 'R':
			if s[i] == 'L':
				if (i - curr[1]) % 2 == 0:
					res += 1
				curr = ('L', i)
		i += 1
	print(res)
main()


n = int(input())
domino = input()
currLetter = None
prev = 0
res = 0
for i in range(n):
	if domino[i] == 'L':
		count = i - prev + 1
		if currLetter == 'R':
			if count % 2 != 0:
				count -= 1
		res += count
		prev = i
		currLetter = 'L'
	if domino[i] == 'R':
		if currLetter == 'R':
			res += i - prev + 1
			print(res)
		else:
			currLetter = 'R'
		prev = i
if currLetter == 'R':
	res += n - prev
print(n - res)


input()
s = input() + 'R'
last = 'L'
ix = -1
cnt = 0
for (i, v) in enumerate(s):
	if v == 'R':
		if last == 'L':
			cnt += i - ix - 1
		ix = i
		last = 'R'
	elif v == 'L':
		if last == 'R' and (i - ix) % 2 == 0:
			cnt += 1
		last = 'L'
		ix = i
print(cnt)


import sys
import math
n = int(sys.stdin.readline())
st = sys.stdin.readline()
c = 0
i = 0
while i < n:
	if st[i] == '.':
		c += 1
	elif st[i] == 'R':
		j = i
		p = 0
		while j < n:
			if st[j] == 'L':
				p = 1
				break
			j += 1
		if p != 0:
			t = int(j - i) + 1
			if t % 2 != 0:
				c += 1
		i = j
	else:
		c = 0
	i += 1
print(c)


n = int(input())
s = input()
l = 0
r = 0
last = None
l_pos = 0
r_pos = 0
ans = 0
for i in range(len(s)):
	if s[i] == 'R' and l == 0:
		ans += i
		r = 1
		r_pos = i
	elif s[i] == 'L' and r == 0:
		l_pos = i
		l = 1
	elif s[i] == 'R' and l == 1:
		ans += i - l_pos - 1
		l = 0
		r = 1
		r_pos = i
	elif s[i] == 'L' and r == 1:
		if (i - r_pos) % 2 == 0:
			ans += 1
		l = 1
		l_pos = i
		r = 0
x = s[::-1]
for i in range(len(x)):
	if x[i] == 'L':
		ans += i
		break
	if x[i] == 'R':
		break
if l == 0 and r == 0:
	print(len(s))
else:
	print(ans)


import sys
index = 0
length = 0
for line in sys.stdin:
	total = 0
	start = False
	rcount = 0
	rtrig = False
	if index == 0:
		length = int(line)
		index += 1
		continue
	for i in range(len(line)):
		if not start:
			if line[i] == 'L':
				total += i + 1
				start = True
			if line[i] == 'R':
				rcount = i
				rtrig = True
				start = True
		elif line[i] == 'R':
			rcount = i
			rtrig = True
		elif line[i] == 'L':
			total += int(int((i - rcount + 1) / 2) * 2)
			rtrig = False
	if rtrig:
		total += length - rcount
	sys.stdout.write(str(length - total))


def num_standing(s):
	ret = 0
	l = [i for (i, x) in enumerate(s) if x == 'L']
	r = [i for (i, x) in enumerate(s) if x == 'R']
	for i in range(len(l)):
		if l[i] % 2 == r[i] % 2:
			ret += 1
	for i in range(1, len(r)):
		ret += r[i] - l[i - 1] - 1
	return ret
n = int(input())
s = input()
L_i = [i for (i, x) in enumerate(s) if x == 'L']
R_i = [i for (i, x) in enumerate(s) if x == 'R']
if len(L_i) == 0 and len(R_i) == 0:
	print(n)
elif len(L_i) == 0:
	print(R_i[0])
elif len(R_i) == 0:
	print(n - L_i[0] - 1)
else:
	standing = 0
	if R_i[0] < L_i[0]:
		standing += R_i[0]
		if R_i[-1] > L_i[-1]:
			standing += R_i[-1] - L_i[-1] - 1
		else:
			standing += n - L_i[-1] - 1
		standing += num_standing(s[R_i[0]:L_i[-1] + 1])
	else:
		standing += R_i[0] - L_i[0] - 1
		if R_i[-1] > L_i[-1]:
			standing += R_i[-1] - L_i[-1] - 1
		else:
			standing += n - L_i[-1] - 1
		standing += num_standing(s[R_i[0]:L_i[-1] + 1])
		if len(L_i) == 1 and len(R_i) == 1:
			standing //= 2
	print(standing)


n = int(input())
l = input()
s = []
t = []
checkvalue = 0
sum = 0
for i in range(len(l)):
	if l[i] == 'L':
		s.append(0)
	elif l[i] == 'R':
		s.append(1)
if s == []:
	sum = n
else:
	if s[0] == 1:
		checkvalue = 1
	for i in range(len(l)):
		if l[i] == 'L' or l[i] == 'R':
			t.append(i)
	if len(t) == 1:
		if checkvalue == 0:
			sum = n - 1 - t[0]
		else:
			sum = t[0]
	else:
		for i in range(len(t) - 1):
			if checkvalue == 0:
				if i % 2 == 0:
					sum += t[i + 1] - t[i] - 1
				else:
					sum += (t[i + 1] - t[i] - 1) % 2
			elif i % 2 == 1:
				sum += t[i + 1] - t[i] - 1
			else:
				sum += (t[i + 1] - t[i] - 1) % 2
		if s[len(t) - 1] == 0:
			sum += n - 1 - t[-1]
		if s[0] == 1:
			sum += t[0]
print(sum)


n = int(input())
s = input().split('L')
ans = 0
if 'R' not in s[0]:
	if len(s) != 1:
		s = s[1:]
if 'R' in s[-1]:
	s[-1] = s[-1][:s[-1].index('R')]
for sub in s:
	if 'R' not in sub:
		ans += len(sub)
	else:
		idx = sub.index('R')
		ans += idx
		ans += (len(sub) - idx - 1) % 2
print(ans)


import sys, math, heapq
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 = ii()
a = la()
ans = 0
s = []
count = 0
for i in range(n):
	if a[i] == '.':
		count += 1
	elif a[i] == 'L':
		if s and s[-1] == 'R':
			ans += count % 2
			s = []
		count = 0
	elif a[i] == 'R':
		s.append('R')
		ans += count
		count = 0
if not s:
	ans += count
print(ans)


def solve(arr, n):
	ans = 0
	i = 0
	blank_count = 0
	last = -1
	while i < n:
		if arr[i] == 'L':
			last = i
			blank_count = 0
		elif arr[i] == 'R':
			last = i
			ans += blank_count
			blank_count = 0
			for j in range(i + 1, n):
				if arr[j] == 'L':
					last = j
					ans += j - i - 1 & 1
					i = j
					break
		else:
			blank_count += 1
		i += 1
	else:
		if arr[last] == 'L':
			ans += blank_count
		if last == -1:
			ans += blank_count
	return ans
n = int(input())
arr = list(input())
print(solve(arr, n))


n = int(input())
st = list(input())
ans = 0
i = 0
while st and i < len(st):
	if st[i] == 'L':
		n -= i + 1
		st = st[i + 1:]
		i = -1
	elif st[i] == 'R':
		n -= 1
		j = i + 1
		while j < len(st):
			if st[j] == 'L':
				n -= j - i
				if (j - i) % 2 == 0:
					n += 1
				st = st[j + 1:]
				i = -1
				break
			if st[j] == 'R':
				n -= j - i - 1
				st = st[j:]
				i = -1
				break
			j += 1
		else:
			n -= j - i - 1
	i += 1
print(n)


import sys
n = int(input())
a = list(input())
c = 0
if set(a) == {'.'}:
	print(n)
	sys.exit()
for x in range(n):
	if a[x] == '.':
		y = x - 1
		z = x + 1
		while y >= 0:
			if a[y] == 'R' or a[y] == 'L':
				break
			y -= 1
		while z < n:
			if a[z] == 'R' or a[z] == 'L':
				break
			z += 1
		if y == -1 and a[z] == 'R':
			c += 1
		elif a[y] == 'L' and z == n:
			c += 1
		elif z < n and y >= 0:
			if a[y] == 'L' and a[z] == 'R':
				c += 1
			elif a[y] == 'R' and a[z] == 'L' and (x - y == z - x):
				c += 1
print(c)


R = lambda : list(map(int, input().split()))
n = int(input())
s = list(input())
m = True
while m:
	m = False
	ws = [x for x in s]
	for i in range(n):
		if s[i] == 'L':
			if i > 0 and s[i - 1] == '.':
				if i == 1 or s[i - 2] != 'R':
					ws[i - 1] = 'L'
					m = True
		elif s[i] == 'R':
			if i < n - 1 and s[i + 1] == '.':
				if i == n - 2 or s[i + 2] != 'L':
					ws[i + 1] = 'R'
					m = True
	s = ws
rs = 0
for x in s:
	if x == '.':
		rs += 1
print(rs)


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')
from collections import defaultdict
from math import ceil, floor, sqrt, log2, gcd
from heapq import heappush, heappop
import sys
abc = 'abcdefghijklmnopqrstuvwxyz'
n = int(input())
s = input()
arr = [0 for _ in range(n)]
for i in range(n):
	if s[i] == 'R':
		arr[i] = 1
		val = 1
		for j in range(i + 1, n):
			if s[j] == 'L':
				break
			val += 1
			arr[j] = val
l = [0 for _ in range(n)]
for i in range(n - 1, -1, -1):
	if s[i] == 'L':
		l[i] = 1
		val = 1
		for j in range(i - 1, -1, -1):
			if s[j] == 'R':
				break
			val += 1
			l[j] = val
c = 0
for i in range(n):
	if l[i] == arr[i]:
		c += 1
print(c)


import sys
input = sys.stdin.readline
n = int(input())
s = input().strip()
st = []
up = n
for i in range(n):
	if s[i] == 'L':
		if not st:
			up -= i + 1
		else:
			length = i - st.pop() + 1
			length -= length % 2
			up -= length
	elif s[i] == 'R':
		st.append(i)
if st:
	up -= n - st.pop()
print(up)


n = int(input())
a = input()
a = list(a)
(l1, l2) = (['.'] * n, ['.'] * n)
(aL, aR) = (0, 0)
for i in range(n):
	if a[i] == 'R':
		aR = 1
		l1[i] = 'R'
		cR = 1
	elif a[i] == '.' and aR == 1:
		l1[i] = cR
		cR += 1
	else:
		aR = 0
		cR = 1
	if a[-1 - i] == 'L':
		aL = 1
		l2[-i - 1] = 'L'
		cL = -1
	elif a[-1 - i] == '.' and aL == 1:
		l2[-i - 1] = cL
		cL -= 1
	else:
		aL = 0
		cL = 1
ans = 0
for i in range(n):
	if type(l1[i]) == int and type(l2[i]) == int:
		if l1[i] + l2[i] == 0:
			ans += 1
	if l1[i] == l2[i]:
		ans += 1
print(ans)


n = int(input())
s = input()
c = 0
f = False
last = ''
for i in range(n):
	if s[i] == '.' and f == False:
		c += 1
	elif s[i] == 'L' and f == False:
		c = 0
		f = True
		k = i
		last = s[i]
	elif s[i] == 'R' and f == False:
		f = True
		last = s[i]
		k = i
	elif s[i] == 'R':
		c += i - k - 1
		k = i
		last = s[i]
	elif s[i] == 'L':
		if (i - k) % 2 == 0:
			c += 1
		k = i
		last = s[i]
if last == 'L':
	c += i - k
print(c)


(n, prev, prch, val) = (int(input()), -1, 'L', 0)
for (i, d) in enumerate(input()):
	if d == 'L':
		if prev != -1 and (i - prev) % 2 == 0:
			val += 1
		(prev, prch) = (i, d)
	elif d == 'R':
		val += i - prev - 1
		(prev, prch) = (i, d)
if prch == 'L':
	val += n - prev - 1
print(val)


def run():
	n = int(input())
	card = input()
	cnt = 0
	start = True
	ans = 0
	last = '.'
	for i in range(n):
		if card[i] == '.':
			cnt += 1
		elif card[i] == 'L':
			if start == True:
				start = False
				cnt = 0
			else:
				ans += cnt % 2
				cnt = 0
			last = 'L'
		else:
			start = False
			ans += cnt
			cnt = 0
			last = 'R'
	if last != 'R':
		ans += cnt
	print(ans)
run()


from sys import stdin, stdout
from bisect import bisect_left
st = lambda : list(stdin.readline().strip())
li = lambda : list(map(int, stdin.readline().split()))
mp = lambda : map(int, stdin.readline().split())
inp = lambda : int(stdin.readline())
pr = lambda n: stdout.write(str(n) + '\n')

def solve():
	n = inp()
	s = st()
	L = [i for i in range(n) if s[i] == 'L']
	R = [i for i in range(n) if s[i] == 'R']
	if not L and (not R):
		pr(n)
		return
	if not L and R:
		pr(R[0])
		return
	if not R and L:
		pr(n - 1 - L[-1])
		return
	ans = 0
	for i in R:
		a = bisect_left(L, i)
		if a != len(L):
			if (L[a] - i) % 2 == 0:
				ans += 1
	if R[0] < L[0]:
		ans += R[0]
	if L[-1] > R[-1]:
		ans += n - 1 - L[-1]
	for i in L:
		a = bisect_left(R, i)
		if a != len(R):
			ans += R[a] - i - 1
	pr(ans)
for _ in range(1):
	solve()


n = int(input())
l = list(input())
s = 0
i = 0
for (i, c) in enumerate(l):
	if c == '.':
		continue
	elif c == 'L':
		for j in range(i + 1):
			l[j] = 'L'
	else:
		break
i = 0
while i < n:
	if l[i] == '.':
		s += 1
	elif l[i] == 'R':
		j = i + 1
		while j < n and l[j] == '.':
			j += 1
		if j != n and (j - i) % 2 == 0:
			s += 1
		i = j
	i += 1
print(s)


n = int(input())
s = k = 0
for (i, x) in enumerate(input(), 1):
	if x == 'R':
		k = i
	elif x == 'L':
		if k:
			s += (k + i + 1) % 2
		else:
			s = 0
		k = 0
	elif not k:
		s += 1
print(s)


n = int(input())
s = str(input())
(count, p) = (0, 0)
while p < n:
	if s[p] == 'R' or s[p] == 'L':
		sp = p + 1
		while sp < n:
			if s[sp] != 'R' and s[sp] != 'L':
				sp += 1
			else:
				break
		if sp == n:
			break
		size = sp - p - 1
		if s[p] == 'R' and s[sp] == 'L':
			count += size % 2
		else:
			count += size
		p = sp
	else:
		p += 1
for j in range(n):
	if s[j] == 'R' or s[j] == 'L':
		break
if s[j] != 'L':
	count += j
temp = 0
limit = j
for j in range(n - 1, limit - 1, -1):
	if s[j] == 'R' or s[j] == 'L':
		break
	temp += 1
if s[j] != 'R':
	count += temp
print(count)


n = int(input())
a = input()

def work(a, b):
	l = [-1] * n
	for i in range(0, n):
		if a[i] == '.':
			l[i] = l[i - 1]
		elif a[i] != b:
			l[i] = -1
		else:
			l[i] = i
	return l
l = work(a, 'R')
r = work(a[::-1], 'L')[::-1]
print(sum((l[i] == -1 and r[i] == -1 or ((l[i] != -1 and r[i] != -1 and (n - r[i] - 1 + l[i] == 2 * i)) and a[i] == '.') for i in range(0, n))))


def oneStandR(i, push):
	interval = 1
	while push[i] != 'L':
		interval += 1
		i += 1
		if i >= n:
			return (0, i)
	if interval % 2 == 1:
		return (1, i)
	else:
		return (0, i)
n = int(input())
push = list(input())
counter = 0
i = 0
while i < n and push[i] == '.':
	i += 1
	counter += 1
if i == n:
	print(counter)
	exit()
if push[i] == 'R':
	while i < n:
		(add, i) = oneStandR(i, push)
		counter += add
		i += 1
		while i < n and push[i] != 'R':
			i += 1
			counter += 1
else:
	counter = 0
	i += 1
	while i < n and push[i] != 'R':
		i += 1
		counter += 1
	while i < n:
		(add, i) = oneStandR(i, push)
		counter += add
		i += 1
		while i < n and push[i] != 'R':
			i += 1
			counter += 1
print(counter)


x = int(input())
l = list(input())
s = 0
rl = [[l[i], i] for i in range(len(l)) if l[i] != '.']
if len(rl) == 0:
	print(len(l))
else:
	answer = 0
	if len(rl) >= 2:
		for i in range(len(rl) - 1):
			if rl[i][0] == 'L' and rl[i + 1][0] == 'R':
				answer += rl[i + 1][-1] - rl[i][-1] - 1
			elif rl[i][0] == 'R' and rl[i + 1][0] == 'L':
				answer += (rl[i + 1][-1] - rl[i][-1] - 1) % 2
		if rl[0][0] == 'R':
			answer += rl[0][-1]
		if rl[-1][0] == 'L':
			answer += len(l) - rl[-1][-1] - 1
	elif rl[0][0] == 'R':
		answer += rl[0][-1]
	elif rl[-1][0] == 'L':
		answer += len(l) - rl[-1][-1] - 1
	print(answer)


n = int(input())
output = 0
r = 0
l = 0
s = 0
tmp = 0
lst = list(input())
for i in range(n):
	if lst[i] is 'L':
		if r is not 0:
			output += tmp % 2
			r = 0
			l = 0
		tmp = 0
	if lst[i] is 'R':
		r = 1
		output += tmp
		tmp = 0
	if lst[i] is '.':
		tmp += 1
print(output + tmp if r is 0 else output)


n = int(input())
s = input().strip()
r = -1
l = -1
cb = 0
res = 0
for i in range(len(s)):
	if s[i] == '.':
		cb += 1
	elif s[i] == 'L':
		if r > -1:
			if cb % 2 == 1:
				res += 1
			cb = 0
		else:
			cb = 0
		r = -1
	elif r > -1:
		cb = 0
		r = i
	else:
		r = i
		res += cb
		cb = 0
if r == -1:
	res += cb
print(res)


n = input()
falling_dir = input()
n = int(n, 10)
f = 0
start_pos = 0
fall_dir = '.'
i = 0
for dir in falling_dir:
	if dir == 'R':
		fall_dir = dir
		start_pos = i
	elif dir == 'L':
		k = i - start_pos
		if fall_dir == '.':
			f += k + 1
		elif k % 2 == 0:
			f += k
		else:
			f += k + 1
		fall_dir = '.'
	i += 1
if fall_dir == 'R':
	k = n - start_pos
	f += k
print(n - f)


input()
s = list(input())
i = 0
while i < len(s):
	r = 0
	if s[i] == 'L':
		for x in range(s.index('L') + 1):
			s.pop(0)
			i -= 1
	elif s[i] == 'R':
		while s[i] != 'L' and i + 1 < len(s):
			r += 1
			i += 1
		if s[i] == 'L':
			i -= r
			if len(s[i:i + r + 1]) % 2 == 1:
				for x in range(r // 2):
					s.pop(i)
				i += 1
				for x in range(r // 2):
					s.pop(i)
				i -= 1
			else:
				for x in range(r + 1):
					s.pop(i)
				i -= 1
		else:
			i -= r
			for x in range(r + 1):
				s.pop(i)
			i -= 1
	i += 1
print(len(s))


n = int(input())
s = list(input())
q = 1
while q:
	q = 0
	for i in range(n):
		if s[i] == 'L':
			if i:
				if s[i - 1] == '.':
					s[i - 1] = 'l'
					q += 1
				elif s[i - 1] == 'r':
					s[i - 1] = '.'
					q -= 1
		elif s[i] == 'R':
			if i + 1 != n:
				if s[i + 1] == '.':
					s[i + 1] = 'r'
					q += 1
				elif s[i + 1] == 'l':
					s[i + 1] = '.'
					q -= 1
	for i in range(n):
		if s[i] == 'r':
			s[i] = 'R'
		elif s[i] == 'l':
			s[i] = 'L'
print(s.count('.'))


n = int(input())
s = input()
a = []
minus = []
plus = []
ans = 0
noo = 0
if len(s) == 1:
	if s[0] != 'L' and s[0] != 'R':
		print(1)
		exit()
	else:
		print(0)
		exit()
for i in range(n):
	if s[i] == 'L':
		a.append(-1)
		noo += 1
	elif s[i] == 'R':
		a.append(1)
		noo += 1
	else:
		a.append(0)
for j in range(n):
	if a[j] == -1:
		minus.append(j)
	if a[j] == 1:
		plus.append(j)
p = len(plus)
m = len(minus)
if noo == 0:
	print(n)
	exit()
if m or p:
	if len(plus) > len(minus):
		ans += plus[0]
	if len(plus) < len(minus):
		ans += n - minus[-1] - 1
	if len(plus) == len(minus):
		if plus[0] < minus[0]:
			ans += plus[0]
			ans += n - minus[-1] - 1
if m and p:
	if plus[0] > minus[0]:
		pp = 0
		l = 1
	else:
		pp = 0
		l = 0
x = min(len(plus), len(minus))
if m and p:
	while pp < len(plus) and l < len(minus):
		dif = (minus[l] + plus[pp]) % 2
		if dif == 0:
			ans += 1
		pp += 1
		l += 1
if m and p:
	if plus[0] < minus[0]:
		d = 1
		l = 0
	else:
		d = 0
		l = 0
if m and p:
	while l < len(minus) and d < len(plus):
		f = plus[d] - minus[l] - 1
		ans += f
		l += 1
		d += 1
print(ans)


input()
k = x = 0
for (i, ch) in enumerate(input(), 1):
	if ch == 'R':
		k = i
	elif ch == 'L':
		x = x + (k + i + 1) % 2 if k else 0
		k = 0
	elif not k:
		x += 1
print(x)


n = int(input())
s = input()
s = list(s)
v = 0
while True:
	lExits = False
	rExits = False
	if 'L' in s:
		l = s.index('L')
		lExits = True
	if 'R' in s:
		r = s.index('R')
		rExits = True
	if lExits == False and rExits == False:
		break
	if lExits == True and rExits == False:
		for i in range(l + 1):
			s[i] = 'F'
		break
	if lExits == False and rExits == True:
		for i in range(r, n):
			s[i] = 'F'
		break
	if lExits == True and rExits == True:
		if l < r:
			for i in range(l + 1):
				s[i] = 'F'
		else:
			for i in range(r, l + 1):
				s[i] = 'F'
			if (l - r) % 2 == 0:
				s[r] = '.'
c = 0
for i in s:
	if i == '.':
		c += 1
print(c)