Pasha has many hamsters and he makes them work out. Today, n hamsters (n is even) came to work out. The hamsters lined up and each hamster either sat down or stood up.

For another exercise, Pasha needs exactly $\frac{n}{2}$ hamsters to stand up and the other hamsters to sit down. In one minute, Pasha can make some hamster ether sit down or stand up. How many minutes will he need to get what he wants if he acts optimally well?


-----Input-----

The first line contains integer n (2 ≤ n ≤ 200; n is even). The next line contains n characters without spaces. These characters describe the hamsters' position: the i-th character equals 'X', if the i-th hamster in the row is standing, and 'x', if he is sitting.


-----Output-----

In the first line, print a single integer — the minimum required number of minutes. In the second line, print a string that describes the hamsters' position after Pasha makes the required changes. If there are multiple optimal positions, print any of them.


-----Examples-----
Input
4
xxXx

Output
1
XxXx

Input
2
XX

Output
1
xX

Input
6
xXXxXx

Output
0
xXXxXx

Difficulty: EASY

Solutions:
n = int(input())
s = input()
(u, d) = (0, 0)
for i in s:
	if i == 'X':
		u = u + 1
	else:
		d = d + 1
if u > d:
	print(n // 2 - d)
elif u == d:
	print(0)
else:
	print(n // 2 - u)
if u == d:
	print(s)
elif u > d:
	v = n // 2 - d
	new = ''
	for i in s:
		if v != 0 and i == 'X':
			new = new + 'x'
			v = v - 1
		else:
			new = new + i
	print(new)
else:
	v = n // 2 - u
	new = ''
	for i in s:
		if v != 0 and i == 'x':
			new = new + 'X'
			v = v - 1
		else:
			new = new + i
	print(new)


n = int(input())
line = input()
up = 0
down = 0
for x in line:
	if x == 'x':
		down += 1
	else:
		up += 1
print(int(abs(up - down) / 2))
for x in line:
	if up < down and x == 'x':
		print('X', end='')
		up += 1
		down -= 1
	elif down < up and x == 'X':
		print('x', end='')
		down += 1
		up -= 1
	else:
		print(x, end='')


def main(s):
	isl = 0
	isu = 0
	for i in s:
		if i.isupper():
			isu += 1
		else:
			isl += 1
	retstr = int(abs(isl - isu) / 2)
	k = 0
	i = 0
	for j in s:
		if isl < isu and k < retstr and j.isupper():
			s[i] = j.lower()
			k += 1
		elif isl > isu and k < retstr and j.islower():
			s[i] = j.upper()
			k += 1
		i += 1
	s = ''.join(s)
	return str(retstr) + '\n' + s
n = input()
srting = list(input())
print(main(srting))


(n, s) = (int(input()), input())
res = max((s.count('X'), 1), (s.count('x'), 0))
if res[1]:
	s = s.replace('X', 'x', res[0] - n // 2)
else:
	s = s.replace('x', 'X', res[0] - n // 2)
print(res[0] - n // 2, s, sep='\n')


n = int(input())
s = input()
(X, x) = (s.count('X'), s.count('x'))
out = n // 2 - min(X, x)
if X > x:
	s = s.replace('X', 'x', out)
elif x > X:
	s = s.replace('x', 'X', out)
print(out, s, sep='\n')


n = int(input())
s = list(input())
count = s.count('X')
if count < n // 2:
	t = count
	for i in range(n):
		if t < n // 2 and s[i] == 'x':
			s[i] = 'X'
			t += 1
	print(t - count)
	print(''.join(s))
elif count > n // 2:
	t = count
	for i in range(n):
		if t > n // 2 and s[i] == 'X':
			s[i] = 'x'
			t -= 1
	print(count - t)
	print(''.join(s))
else:
	print(0)
	print(''.join(s))


n = int(input())
s = list(input())
X = s.count('X')
x = s.count('x')
ans = 0
for i in range(n):
	if X > x and s[i] == 'X':
		s[i] = 'x'
		ans += 1
		X -= 1
		x += 1
	elif X < x and s[i] == 'x':
		s[i] = 'X'
		ans += 1
		X += 1
		x -= 1
print(ans)
for item in s:
	print(item, end='')


import fileinput

def test():
	pass
num_args = 2
for arg in range(num_args):
	if arg == 0:
		n = int(input())
	else:
		h = input()
h = list(h)
stand = []
sit = []
num_stand = 0
for i in range(len(h)):
	if h[i] == 'X':
		num_stand += 1
		stand.append(i)
	else:
		sit.append(i)
if len(sit) > n / 2:
	for j in range(0, len(sit) - n // 2):
		h[int(sit[j])] = 'X'
elif len(stand) > n / 2:
	for j in range(0, len(stand) - n // 2):
		h[int(stand[j])] = 'x'
num_min = int(abs(n / 2 - num_stand))
print(num_min)
str1 = ''.join(h)
print(str1)


n = int(input())
s = input()
sit = 0
stand = 0
for h in s:
	if h == 'x':
		sit += 1
	else:
		stand += 1
if sit == stand:
	print('0')
	print(s)
else:
	needChanged = (stand - sit) // 2
	if needChanged < 1:
		needChanged *= -1
		print(needChanged)
		print(s.replace('x', 'X', needChanged))
	else:
		print(needChanged)
		print(s.replace('X', 'x', needChanged))


from sys import stdin, stdout
import collections
n = int(stdin.readline())
inp = stdin.readline().strip()
counter = collections.Counter(inp)
if counter['X'] == n // 2:
	stdout.write('0\n' + inp + '\n')
else:
	reqA = n // 2 - counter['X']
	reqB = n // 2 - counter['x']
	if reqA > reqB:
		stdout.write(str(reqA) + '\n')
		for i in inp:
			if i == 'x' and reqA > 0:
				stdout.write('X')
				reqA -= 1
			else:
				stdout.write(i)
	else:
		stdout.write(str(reqB) + '\n')
		for i in inp:
			if i == 'X' and reqB > 0:
				stdout.write('x')
				reqB -= 1
			else:
				stdout.write(i)


n = int(input())
x = input()
s = ''
stand = 0
sit = 0
for i in range(n):
	if x[i] == 'X':
		stand = stand + 1
	else:
		sit = sit + 1
b = n // 2
minutes = 0
if stand == b and sit == b:
	print(minutes)
	print(x)
else:
	minutes = minutes + (max(stand, sit) - b)
	d = max(stand, sit)
	e = min(stand, sit)
	if d == stand:
		f = 'x'
	else:
		f = 'X'
	g = n // 2 - e
	counter = 0
	for j in range(n):
		if counter < g and x[j] != f:
			s = s + f
			counter = counter + 1
		else:
			s = s + x[j]
	print(minutes)
	print(s)


n = int(input())
s = input()
m = s.count('X')
c = abs(n // 2 - m)
print(c)
if m < n // 2:
	print(str.replace(s, 'x', 'X', c))
else:
	print(str.replace(s, 'X', 'x', c))


n = int(input())
s = input()
d = s.count('x')
c = abs(d - n // 2)
if d < n // 2:
	s = s.replace('X', 'x', c)
else:
	s = s.replace('x', 'X', c)
print(c)
print(s)


n = int(input())
pos1 = list(input())
down = 0
up = 0
for c in pos1:
	if c == 'x':
		down += 1
	else:
		up += 1
if up > down:
	r = up - n / 2
	print(int(r))
	for i in range(len(pos1)):
		if pos1[i] == 'X':
			pos1[i] = 'x'
			r -= 1
		if r == 0:
			break
elif up < down:
	r = down - n / 2
	print(int(r))
	for i in range(len(pos1)):
		if pos1[i] == 'x':
			pos1[i] = 'X'
			r -= 1
		if r == 0:
			break
else:
	print(0)
pos2 = str()
for c in pos1:
	pos2 += c
print(pos2)


n = int(input())
hams = list(input())
sitting = hams.count('x')
standing = hams.count('X')
mins = 0
if sitting > standing:
	needed = sitting - n // 2
	i = 0
	while needed > 0:
		if hams[i] == 'x':
			hams[i] = 'X'
			mins += 1
			needed -= 1
		i += 1
elif sitting < standing:
	needed = standing - n // 2
	i = 0
	while needed > 0:
		if hams[i] == 'X':
			hams[i] = 'x'
			mins += 1
			needed -= 1
		i += 1
print(mins)
print(''.join(hams))


squats_num = int(input(''))
squats = input('')
(sit, stay) = (0, 0)
for squat in squats:
	if squat == 'x':
		sit += 1
	else:
		stay += 1
bal = squats_num // 2
if squats_num - sit < squats_num - stay:
	print(sit - bal)
	new_pos = []
	for i in range(len(squats)):
		if sit > bal and squats[i] == 'x':
			new_pos.append('X')
			sit -= 1
		else:
			new_pos.append(squats[i])
	print(''.join(new_pos))
else:
	print(stay - bal)
	new_pos = []
	for i in range(len(squats)):
		if stay > bal and squats[i] == 'X':
			new_pos.append('x')
			stay -= 1
		else:
			new_pos.append(squats[i])
	print(''.join(new_pos))


(n, i) = (int(input()), list(input()))
if i.count('X') <= n // 2:
	a = 'X'
	b = i.count(a)
else:
	a = 'x'
	b = i.count(a)
print(n // 2 - b)
for z in range(n):
	if i.count(a) == n // 2:
		print(''.join(i))
		break
	if i[z] != a:
		i[z] = a


n = int(input())
s = input()
r = (n >> 1) - s.count('x')
c = abs(r)
print(c)
i = 0
if r > 0:
	while c:
		if s[i] == 'X':
			print('x', end='')
			c -= 1
		else:
			print(s[i], end='')
		i += 1
	print(s[i:])
elif r < 0:
	while c:
		if s[i] == 'x':
			print('X', end='')
			c -= 1
		else:
			print(s[i], end='')
		i += 1
	print(s[i:])
else:
	print(s)


n = int(input())
s = input()
c1 = s.count('x')
c2 = s.count('X')
s = s.replace('x', 'X', max(0, (c1 - c2) // 2))
s = s.replace('X', 'x', max(0, (c2 - c1) // 2))
print(abs(c2 - c1) // 2)
print(s)


n = int(input())
a = input()
a = list(a)
v1 = a.count('x')
v2 = a.count('X')
f = n // 2 - min(v1, v2)
print(n // 2 - min(v1, v2))
if v1 > v2:
	for i in range(n):
		if f == 0:
			break
		if a[i] == 'x':
			a[i] = 'X'
			f -= 1
else:
	for i in range(n):
		if f == 0:
			break
		if a[i] == 'X':
			a[i] = 'x'
			f -= 1
for i in range(n):
	print(a[i], end='')


n = int(input())
s = input()
a = list(s)
k = s.count('X') - s.count('x')
(c, r) = ('xX'[k > 0], 'xX'[k < 0])
print(abs(k) // 2)
for (i, x) in enumerate(s):
	if k and x == c:
		a[i] = r
		k -= (-2, 2)[k > 0]
print(''.join(a))


import sys

def fastio():
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

def debug(*var, sep=' ', end='\n'):
	print(*var, file=sys.stderr, end=end, sep=sep)
INF = 10 ** 20
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br
(n,) = I()
a = list(input())
x = a.count('x')
X = a.count('X')
ans = abs(X - x) // 2
if x > X:
	for i in range(n):
		if a[i] == 'x' and x != X:
			a[i] = 'X'
			x -= 1
			X += 1
if x < X:
	for i in range(n):
		if a[i] == 'X' and x != X:
			a[i] = 'x'
			x += 1
			X -= 1
print(ans)
print(''.join(a))


n = int(input())
s = input().strip()
xsmall = s.count('x')
xbig = s.count('X')
if xbig < xsmall:
	print((xsmall - xbig) // 2)
	print(s.replace('x', 'X', (xsmall - xbig) // 2))
else:
	print((xbig - xsmall) // 2)
	print(s.replace('X', 'x', (xbig - xsmall) // 2))


n = int(input())
a = input().strip()
cnt = 0
a = list(a)
for i in range(n):
	if a[i] == 'x':
		cnt += 1
res = abs(n // 2 - max(cnt, n - cnt))
print(res)
if cnt > n - cnt:
	for i in range(n):
		if a[i] == 'x' and res:
			a[i] = 'X'
			res -= 1
else:
	for i in range(n):
		if a[i] == 'X' and res:
			a[i] = 'x'
			res -= 1
print(''.join(a))


ham_count = int(input())
order = input()
final_order = order
small_count = 0
big_count = 0
for i in order:
	if i == 'x':
		small_count = small_count + 1
	else:
		big_count = big_count + 1
if small_count > big_count:
	diff = int((small_count - big_count) / 2)
	print(diff)
	for (i, index) in enumerate(order):
		if diff == 0:
			break
		elif index == 'x':
			final_order = final_order[:i] + 'X' + final_order[i + 1:]
			diff = diff - 1
	print(final_order)
elif big_count > small_count:
	diff = int((big_count - small_count) / 2)
	print(diff)
	for (i, index) in enumerate(order):
		if diff == 0:
			break
		elif index == 'X':
			final_order = final_order[:i] + 'x' + final_order[i + 1:]
			diff = diff - 1
	print(final_order)
else:
	print(0)
	print(order)


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

def main():
	n = int(input())
	A = list(input())
	val = 0
	for a in A:
		if a == 'x':
			val += 1
	print(abs(val - n // 2))
	if val == n // 2:
		pass
	elif val < n // 2:
		for i in range(n):
			if val < n // 2 and A[i] == 'X':
				A[i] = 'x'
				val += 1
	elif val > n // 2:
		for i in range(n):
			if val > n // 2 and A[i] == 'x':
				A[i] = 'X'
				val -= 1
	print(''.join(A))
main()


a = int(input())
s = input()
k = len(s)
vstali = 0
seli = 0
s1 = 'c'
seli = s.count('x')
vstali = s.count('X')
if seli > vstali:
	q = (seli - vstali) // 2
	q1 = q
	k1 = 0
	for i in range(k):
		if s[k1] == 'x' and q1 > 0:
			s1 = s1 + 'X'
			q1 -= 1
		elif s[k1] == 'x' and q1 <= 0:
			s1 = s1 + 'x'
		else:
			s1 = s1 + 'X'
		k1 += 1
if seli < vstali:
	q = (vstali - seli) // 2
	q1 = q
	k1 = 0
	for i in range(k):
		if s[k1] == 'X' and q1 > 0:
			s1 = s1 + 'x'
			q1 -= 1
		elif s[k1] == 'X' and q1 <= 0:
			s1 = s1 + 'X'
		else:
			s1 = s1 + 'x'
		k1 += 1
if seli == vstali:
	s1 = s1 + s
	q = 0
print(q)
print(s1[1:k + 1])


n = int(input())
a = list(input())
X = a.count('X')
x = n - X
print(abs(n // 2 - X))
if X > x:
	c = abs(n // 2 - X)
	for i in range(n):
		if c == 0:
			break
		if a[i] == 'X':
			a[i] = 'x'
			c -= 1
else:
	c = abs(n // 2 - X)
	for i in range(n):
		if c == 0:
			break
		if a[i] == 'x':
			a[i] = 'X'
			c -= 1
print(''.join(a))


n = int(input())
line = str(input())
num_stand = 0
for i in range(n):
	if line[i] == 'X':
		num_stand += 1
tar = n // 2
res = 0
if tar > num_stand:
	for i in range(n):
		if line[i] == 'x':
			line = line[:i] + 'X' + line[i + 1:]
			num_stand += 1
			res += 1
		if tar == num_stand:
			break
elif tar < num_stand:
	for i in range(n):
		if line[i] == 'X':
			line = line[:i] + 'x' + line[i + 1:]
			num_stand -= 1
			res += 1
		if tar == num_stand:
			break
print(res)
print(line)


n = int(input())
a = input()
up = 0
for i in a:
	if i == 'X':
		up += 1
diff = n // 2 - up
print(abs(diff))
if diff >= 0:
	print(a.replace('x', 'X', diff))
else:
	print(a.replace('X', 'x', abs(diff)))


n = int(input())
a = list(input())
xa = a.count('x')
xb = a.count('X')
xc = 'x' if xb > xa else 'X'
result = int(abs(n / 2 - xa))
print(result)
for i in a:
	if result == 0:
		break
	if i != xc:
		a[a.index(i)] = xc
		result -= 1
print(''.join(a))


n = int(input())
position = input()
n_X = int(position.count('X'))
t = 0
if n_X < n // 2:
	ele = n // 2 - n_X
	x = 0
	for i in range(n):
		if position[i] == 'x' and x <= ele:
			x += 1
			t += 1
			position = position[:i] + 'X' + position[i + 1:]
			if x == ele:
				break
elif n_X > n // 2:
	ele = n_X - n // 2
	x = 0
	for i in range(n):
		if position[i] == 'X' and x <= ele:
			x += 1
			t += 1
			position = position[:i] + 'x' + position[i + 1:]
			if x == ele:
				break
print(t)
print(position)


hamsters = int(input())
position = list(input())
standing = sum((1 for x in position if x == 'X'))
sitting = sum((1 for x in position if x == 'x'))

def make_stand(li, stand, sit):
	cnt = 0
	mins = 0
	while stand < sit:
		if li[cnt] == 'x':
			li[cnt] = 'X'
			stand += 1
			sit -= 1
			mins += 1
		cnt += 1
	return (li, mins)

def make_sit(li, stand, sit):
	cnt = 0
	mins = 0
	while sit < stand:
		if li[cnt] == 'X':
			li[cnt] = 'x'
			stand -= 1
			sit += 1
			mins += 1
		cnt += 1
	return (li, mins)
if standing == sitting:
	print(0)
	print(''.join(position))
elif standing > sitting:
	out = make_sit(position, standing, sitting)
	print(out[1])
	print(''.join(out[0]))
else:
	out = make_stand(position, standing, sitting)
	print(out[1])
	print(''.join(out[0]))


from collections import defaultdict, deque, Counter, OrderedDict

def main():
	n = int(input())
	s = [c for c in input()]
	d = Counter()
	for c in s:
		d[c] += 1
	(a, b, c) = ('', '', 0)
	if d['X'] > d['x']:
		(a, b) = ('X', 'x')
		c = (d['X'] - d['x']) // 2
	elif d['X'] < d['x']:
		(a, b) = ('x', 'X')
		c = (d['x'] - d['X']) // 2
	else:
		print('0\n' + ''.join(s))
		exit(0)
	ans = c
	for i in range(n):
		if c == 0:
			break
		if s[i] == a:
			s[i] = b
			c -= 1
	print(ans)
	print(''.join(s))
main()


n = int(input())
l = [c for c in input()]
h = n / 2
u = 0
d = 0
ui = []
di = []
for (i, c) in enumerate(l):
	if c == 'X':
		u += 1
		ui.append(i)
	else:
		d += 1
		di.append(i)
if u > h:
	print(int(u - h))
	for i in ui:
		l[i] = 'x'
		u -= 1
		d += 1
		if u == h:
			break
elif d > h:
	print(int(d - h))
	for i in di:
		l[i] = 'X'
		d -= 1
		u += 1
		if d == h:
			break
else:
	print(0)
print(''.join(l))


n = int(input())
s = input()
a = s.count('X')
b = abs(n // 2 - a)
print(b)
if a < n // 2:
	print(str.replace(s, 'x', 'X', b))
else:
	print(str.replace(s, 'X', 'x', b))


n = map(int, input())
a = list(input())
i_x = a.count('x')
i_X = a.count('X')
result = int(abs(i_x - i_X) / 2)
print(result)
cnt = 0
if i_x > i_X:
	flag = 1
elif i_x < i_X:
	flag = 0
else:
	flag = -1
for i in range(len(a)):
	if flag == -1:
		break
	if a[i] == 'x':
		if flag == 1:
			a[i] = 'X'
			cnt += 1
	elif flag == 0:
		a[i] = 'x'
		cnt += 1
	if cnt == result:
		break
print(''.join(a))


n = int(input())
a = list(input())
i = 0
print(max(a.count('x'), a.count('X')) - n // 2)
while a.count('x') != a.count('X'):
	a[i] = ['x', 'X'][a.count('x') > a.count('X')]
	i += 1
print(*a, sep='')


n = int(input())
string = input()
x = string.count('x')
X = n - x
ans = abs(x - n // 2)
if x >= X:
	string = string.replace('x', 'X', ans)
else:
	string = string.replace('X', 'x', ans)
print(ans)
print(string)


n = int(input())
s = str(input())
x = s.count('x')
xo = s.count('X')
if xo == x:
	print(0)
elif x > xo:
	print((x - xo) // 2)
	while x > xo:
		s = s.replace('x', 'X', 1)
		x = s.count('x')
		xo = s.count('X')
		if x == xo:
			break
elif xo > x:
	print((xo - x) // 2)
	while xo > x:
		s = s.replace('X', 'x', 1)
		x = s.count('x')
		xo = s.count('X')
		if x == xo:
			break
print(s)


from math import *
n = int(input())
s = input().strip()
c = 0
k = 0
c = s.count('x')
k = s.count('X')
i = 0
otv = []
print(min(abs(n // 2 - c), abs(n // 2 - k)))
if n // 2 - c > n // 2 - k:
	while i < n and c != n // 2:
		if s[i] == 'X':
			otv += 'x'
			c += 1
		else:
			otv += s[i]
		i += 1
	for j in range(i, n):
		otv += s[j]
elif n // 2 - c < n // 2 - k:
	while i < n and k != n // 2:
		if s[i] == 'x':
			otv += 'X'
			k += 1
		else:
			otv += s[i]
		i += 1
	for j in range(i, n):
		otv += s[j]
else:
	for j in range(n):
		otv += s[j]
print(''.join(otv))


def squats(n, q):
	s = list(q)
	a = 0
	b = 0
	for i in range(len(s)):
		if s[i] == 'x':
			a = a + 1
		else:
			b = b + 1
	if a == b:
		print(0)
		for i in range(len(s)):
			print(s[i], end='')
	elif a > b:
		dif = a - b
		res = 0
		for i in range(len(s)):
			if s[i] == 'x' and a != b:
				s[i] = 'X'
				res = res + 1
				a = a - 1
				b = b + 1
		print(res)
		for i in range(len(s)):
			print(s[i], end='')
	else:
		dif = b - a
		res = 0
		for i in range(len(s)):
			if s[i] == 'X' and a != b:
				s[i] = 'x'
				res = res + 1
				b = b - 1
				a = a + 1
		print(res)
		for i in range(len(s)):
			print(s[i], end='')
n = int(input(''))
s = input('')
squats(n, s)


n = int(input())
a = input()
x = a.count('x')
if 2 * x > n:
	a = a.replace('x', 'X', x - n // 2)
else:
	a = a.replace('X', 'x', n // 2 - x)
print(abs(2 * x - n) // 2)
print(a)


def single_integer():
	return int(input())

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

def string():
	return input()

def multi_string():
	return input().split()
n = single_integer()
x_string = string()
x_count = 0
X_count = 0
final_string = ''
for i in x_string:
	if i == 'x':
		x_count += 1
	else:
		X_count += 1
if x_count == X_count:
	print(0)
	print(x_string)
else:
	diff = abs(n // 2 - max(x_count, X_count))
	print(diff)
	if x_count > X_count:
		for i in x_string:
			if diff > 0:
				if i == 'x':
					final_string += 'X'
					diff -= 1
				else:
					final_string += i
			else:
				final_string += i
	else:
		for i in x_string:
			if diff > 0:
				if i == 'X':
					final_string += 'x'
					diff -= 1
				else:
					final_string += i
			else:
				final_string += i
	print(final_string)


n = int(input())
s = input()
r = s.count('X')
d = abs(n // 2 - r)
print(d)
if r < n // 2:
	print(str.replace(s, 'x', 'X', d))
else:
	print(str.replace(s, 'X', 'x', d))


n = int(input())
s = str(input())
half = n // 2
sit = s.count('x')
stand = s.count('X')
ans = max(sit, stand) - half
t = ans
while ans != 0:
	if sit > stand:
		temp = s.index('x')
		s = s[:temp] + 'X' + s[temp + 1:]
		sit = sit - 1
		stand = stand + 1
		ans = ans - 1
	else:
		temp = s.index('X')
		s = s[:temp] + 'x' + s[temp + 1:]
		sit = sit + 1
		stand = stand - 1
		ans = ans - 1
print(t)
print(s)


def hamster_squat():
	total = int(input())
	hamsters = input()
	dic = {'x': 0, 'X': 0}
	for i in range(len(hamsters)):
		dic[hamsters[i]] += 1
	if dic['x'] == dic['X']:
		print(0)
		print(hamsters)
		return
	sat = dic['x']
	stood = dic['X']
	add_lower = False
	if sat < stood:
		add_lower = True
	maximum = max(sat, stood)
	add = maximum - int((sat + stood) / 2)
	print(add)
	if add_lower:
		output = ''
		hamsters = [i for i in hamsters]
		for i in range(len(hamsters)):
			if add > 0:
				if hamsters[i] == 'X':
					hamsters[i] = 'x'
					add -= 1
			output = output + hamsters[i]
	else:
		output = ''
		hamsters = [i for i in hamsters]
		for i in range(len(hamsters)):
			if add > 0:
				if hamsters[i] == 'x':
					hamsters[i] = 'X'
					add -= 1
			output = output + hamsters[i]
	print(output)
hamster_squat()


n = int(input())
line = list(input())
x = line.count('x')
X = line.count('X')
res = max(x, X) - n // 2
if x < n // 2:
	for i in range(n):
		if line[i] == 'X':
			line[i] = 'x'
			x += 1
		if x == n // 2:
			break
elif x > n // 2:
	for i in range(n):
		if line[i] == 'x':
			line[i] = 'X'
			X += 1
		if n // 2 == X:
			break
print(res)
print(''.join(line))


n = int(input())
s = input()
a = 0
b = 0
s = list(s)
for i in range(n):
	if s[i] == 'x':
		a += 1
	else:
		b += 1
if a > n // 2:
	counter = 0
	for i in range(len(s)):
		if s[i] == 'x' and counter + a > n // 2:
			s[i] = 'X'
			counter -= 1
else:
	counter = 0
	for i in range(len(s)):
		if s[i] == 'X' and counter + b > n // 2:
			s[i] = 'x'
			counter -= 1
print(abs(a - b) // 2)
yay = ''
for i in range(len(s)):
	yay += s[i]
print(yay)


n = int(input())
a = input()
x = a.count('x')
if x > n // 2:
	k = 0
	rez = ''
	z = x - n // 2
	for (i, y) in enumerate(a):
		if y == 'x' and k < z:
			y = 'X'
			k += 1
		rez += y
	print(z)
	print(rez)
elif x < n // 2:
	k = 0
	rez = ''
	z = n // 2 - x
	for (i, y) in enumerate(a):
		if y == 'X' and k < z:
			y = 'x'
			k += 1
		rez += y
	print(z)
	print(rez)
else:
	print(0)
	print(a)


n = int(input())
t = list(input())
p = t.count('X')
q = t.count('x')
if p > q:
	o = 0
	for j in range(n):
		if t[j] == 'X':
			t[j] = 'x'
			o += 1
			if t.count('X') == t.count('x'):
				print(o)
				print(''.join(t))
				break
elif q > p:
	s = 0
	for k in range(n):
		if t[k] == 'x':
			t[k] = 'X'
			s += 1
			if t.count('x') == t.count('X'):
				print(s)
				print(''.join(t))
				break
else:
	print(0)
	print(''.join(t))


n = int(input())
s = list(input())
st = s.count('X')
n2 = n // 2
k = abs(n2 - st)
if st > n2:
	for i in range(n):
		if s[i] == 'X':
			s[i] = 'x'
		if s.count('X') == n2:
			break
elif st < n2:
	for i in range(n):
		if s[i] == 'x':
			s[i] = 'X'
		if s.count('X') == n2:
			break
print(k)
print(''.join(s))


import sys
from functools import reduce
from collections import Counter
import time
import datetime
from math import sqrt, gcd

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

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

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

def mips():
	return map(str, sys.stdin.readline().split())

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

def matip(n, m):
	lst = []
	for i in range(n):
		arr = lip()
		lst.insert(i, arr)
	return lst

def factors(n):
	return list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def minJumps(arr, n):
	jumps = [0 for i in range(n)]
	if n == 0 or arr[0] == 0:
		return float('inf')
	jumps[0] = 0
	for i in range(1, n):
		jumps[i] = float('inf')
		for j in range(i):
			if i <= j + arr[j] and jumps[j] != float('inf'):
				jumps[i] = min(jumps[i], jumps[j] + 1)
				break
	return jumps[n - 1]

def dic(arr):
	return Counter(arr)

def check_prime(n):
	if n < 2:
		return False
	for i in range(2, int(n ** 0.5) + 1, 2):
		if n % i == 0:
			return False
	return True
n = ip()
s = sip()
(up, down) = (0, 0)
lst = []
for i in range(n):
	lst.append(s[i])
	if s[i] == 'X':
		up += 1
	else:
		down += 1
if up == down:
	print(0)
	print(s)
elif up > down:
	recq = n // 2 - down
	print(recq)
	for i in range(n):
		if lst[i] == 'X':
			lst[i] = 'x'
			recq -= 1
			if recq == 0:
				break
	print(''.join(lst))
else:
	recq = n // 2 - up
	print(recq)
	for i in range(n):
		if lst[i] == 'x':
			lst[i] = 'X'
			recq -= 1
			if recq == 0:
				break
	print(''.join(lst))


def Squats(n, seq):
	cntX = seq.count('X')
	cntx = seq.count('x')
	diffCnt = cntx - cntX
	if diffCnt < 0:
		result = seq.replace('X', 'x', abs(int(n / 2) - cntX))
		return (abs(int(n / 2) - cntX), result)
	elif diffCnt > 0:
		result = seq.replace('x', 'X', abs(int(n / 2) - cntX))
		return (abs(int(n / 2) - cntX), result)
	else:
		return (0, seq)
n = int(input())
seq = input()
res = Squats(n, seq)
print(res[0])
print(res[1])


def change_hamster_positions(hamster_positions, dominant_position, passive_position, num_changes_required):
	num_positional_changes = 0
	for index in range(len(hamster_positions)):
		if num_positional_changes < num_changes_required:
			if hamster_positions[index] == dominant_position:
				hamster_positions[index] = passive_position
				num_positional_changes += 1
	return ''.join(hamster_positions)

def equalize_hamster_positions(num_hamsters, hamster_positions):
	num_hamsters_standing = hamster_positions.count('X')
	num_hamsters_sitting = hamster_positions.count('x')
	if num_hamsters_standing == num_hamsters_sitting:
		print(0)
		print(hamster_positions)
		return 0
	num_changes_required = abs(num_hamsters_standing - num_hamsters_sitting) // 2
	hamster_positions = list(map(str, hamster_positions))
	if num_hamsters_standing > num_hamsters_sitting:
		dominant_position = 'X'
		passive_position = 'x'
		hamster_positions_new = change_hamster_positions(hamster_positions, dominant_position, passive_position, num_changes_required)
	if num_hamsters_sitting > num_hamsters_standing:
		dominant_position = 'x'
		passive_position = 'X'
		hamster_positions_new = change_hamster_positions(hamster_positions, dominant_position, passive_position, num_changes_required)
	print(num_changes_required)
	print(hamster_positions_new)
num_hamsters_user = int(input())
hamster_positions_user = input()
equalize_hamster_positions(num_hamsters_user, hamster_positions_user)


n = int(input())
tmp = input()
x = []
for i in range(len(tmp)):
	x.append(tmp[i])
c1 = x.count('X')
c2 = x.count('x')
if c1 == c2:
	res = 0
elif min(c1, c2) == 0:
	res = int(max(c1, c2) / 2) + 1
else:
	res = int(len(tmp) / 2)
	res = int(res - min(c1, c2)) + 1
a = list()
ast = list()
s = ''
if c1 == c2:
	for i in range(len(tmp)):
		s += x[i]
	print(res)
	print(s)
else:
	res -= 1
	t = res
	if c1 > c2:
		for i in range(len(tmp)):
			if x[i] == 'X':
				a.append(i)
		for i in range(t):
			x[a[i]] = 'x'
	else:
		for i in range(len(tmp)):
			if x[i] == 'x':
				a.append(i)
		for i in range(t):
			x[a[i]] = 'X'
	for i in range(len(tmp)):
		s += x[i]
	print(res)
	print(s)


import sys
from collections import defaultdict
from heapq import nlargest
Input = lambda : map(int, input().split())
n = int(input())
s = input()
a = s.count('x')
b = n // 2
print(abs(b - a))
if b < a:
	a -= b
	s = s.replace('x', 'X', a)
elif b > a:
	b -= a
	s = s.replace('X', 'x', b)
print(s)


def main():
	input()
	s = input()
	ta = t = (s.count('x') - s.count('X')) // 2
	res = []
	if t > 0:
		for c in s:
			if t and c == 'x':
				c = 'X'
				t -= 1
			res.append(c)
	else:
		for c in s:
			if t and c == 'X':
				c = 'x'
				t += 1
			res.append(c)
	print(abs(ta))
	print(''.join(res))
main()


n = int(input())
s = list(input())
c = 0
j = 0
for i in s:
	if i == 'X':
		c += 1
if c > n / 2:
	for i in range(len(s)):
		if s[i] == 'X':
			s[i] = 'x'
			c -= 1
			j += 1
			if c == n / 2:
				break
elif c < n / 2:
	for i in range(len(s)):
		if s[i] == 'x':
			s[i] = 'X'
			c += 1
			j += 1
			if c == n / 2:
				break
else:
	pass
s1 = ''.join(s)
print(j)
print(s1)


n = int(input())
s = list(input())
x = len([c for c in s if c == 'x'])
X = len([c for c in s if c == 'X'])
m = n // 2
d = 0
if x == X:
	print(0)
	print(''.join(s))
else:
	if x < X:
		d = m - x
		k = 0
		for i in range(n):
			if s[i] == 'X':
				s[i] = 'x'
				k += 1
			if k == d:
				break
	else:
		d = m - X
		k = 0
		for i in range(n):
			if s[i] == 'x':
				s[i] = 'X'
				k += 1
			if k == d:
				break
	print(d)
	print(''.join(s))


input()
pos = [c == 'X' for c in input()]
b = pos.count(True) - len(pos) // 2
print(abs(b))
if b < 0:
	for p in range(len(pos)):
		if not pos[p]:
			pos[p] = True
			b += 1
			if b == 0:
				break
elif b > 0:
	for p in range(len(pos)):
		if pos[p]:
			pos[p] = False
			b -= 1
			if b == 0:
				break
print(''.join(('X' if p else 'x' for p in pos)))


n = int(input())
s = input()
cnt = s.count('x') - s.count('X')
print(abs(cnt // 2))
s = list(s)
for i in range(len(s)):
	if cnt > 0 and s[i] == 'x':
		s[i] = 'X'
		cnt -= 2
	elif cnt < 0 and s[i] == 'X':
		s[i] = 'x'
		cnt += 2
print(''.join(s))


n = int(input())
s = input()
high = s.count('X')
low = n - high
val = max(high, low)
print(abs(n // 2 - val))
if low == high:
	print(s)
elif low > high:
	ans = ''
	for i in s:
		if low == n // 2:
			ans += i
		elif i == 'X':
			ans += 'X'
		else:
			ans += 'X'
			low -= 1
	print(ans)
else:
	ans = ''
	for i in s:
		if low == n // 2:
			ans += i
		elif i == 'x':
			ans += 'x'
		else:
			ans += 'x'
			low += 1
	print(ans)


N = int(input())
S = list(input())
x = S.count('x')
ans = abs(N // 2 - x)
print(ans)
for i in range(N):
	if S[i] == 'x' and x > N // 2:
		S[i] = 'X'
		x -= 1
	elif S[i] == 'X' and x < N // 2:
		S[i] = 'x'
		x += 1
print(''.join(S))


n = int(input())
s = input()
standing = s.count('X')
count = abs(n // 2 - standing)
print(count)
if standing < n // 2:
	print(str.replace(s, 'x', 'X', count))
else:
	print(str.replace(s, 'X', 'x', count))


n = int(input())
s = input()
if s.count('X') == s.count('x'):
	print(0)
	print(s)
else:
	l = {i: n // 2 - s.count(i) for i in 'Xx'}
	if l['X'] > 0:
		s = s.replace('x', 'X', l['X'])
		print(l['X'])
		print(s)
	else:
		s = s.replace('X', 'x', l['x'])
		print(l['x'])
		print(s)


n = int(input())
s = input()
ans = []
(c, C) = (0, 0)
for i in s:
	if i == 'x':
		c += 1
	else:
		C += 1
if c == C:
	print('0')
	print(s)
else:
	mn = min(c, C)
	if mn == c:
		ch = 'x'
	else:
		ch = 'X'
	val = len(s) // 2 - mn
	print(val)
	for i in s:
		if i != ch and mn < len(s) // 2:
			ans.append(ch)
			mn += 1
		else:
			ans.append(i)
	for j in ans:
		print(j, end='')


n = int(input())
s = list(input())
a = s.count('x')
b = s.count('X')
c = 'x' if a < b else 'X'
k = abs(n // 2 - a)
print(k)
i = 0
while k > 0:
	if s[i] != c:
		s[i] = c
		k -= 1
	i += 1
print(''.join(s))


import os
import sys
from io import BytesIO, IOBase

def main():
	n = int(input())
	s = input()
	cx = 0
	cX = 0
	for x in range(n):
		if s[x] == 'x':
			cx += 1
		else:
			cX += 1
	ans = min(abs(cx - n // 2), abs(cX - n // 2))
	print(ans)
	if ans == abs(cx - n // 2):
		if cx > n // 2:
			ss = s.replace('x', 'X', ans)
			print(ss)
		else:
			ss = s.replace('X', 'x', ans)
			print(ss)
	elif ans == abs(cX - n // 2):
		if cX > n // 2:
			ss = s.replace('X', 'x', ans)
			print(ss)
		else:
			ss = s.replace('x', 'X', ans)
			print(ss)
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')
main()


t = int(input())
n = input()
a = n.count('x')
b = n.count('X')
if a == b:
	print(0)
	print(n)
	exit(0)
elif a > b:
	n = n.replace('x', 'X', a - t // 2)
	print(a - t // 2)
	print(n)
else:
	n = n.replace('X', 'x', b - t // 2)
	print(b - t // 2)
	print(n)


n = int(input())
st = input()
c = 0
lisx = []
lisX = []
for i in range(n):
	if st[i] == 'x':
		c += 1
		lisx.append(i)
	else:
		lisX.append(i)
if c == n // 2:
	print(0)
	print(st)
else:
	print(abs(c - n // 2))
	if c > n // 2:
		d = c - n // 2
		lis_st = list(st)
		for i in range(d):
			lis_st[lisx[i]] = 'X'
		print(''.join(lis_st))
	else:
		d = len(lisX) - n // 2
		lis_st = list(st)
		for i in range(d):
			lis_st[lisX[i]] = 'x'
		print(''.join(lis_st))


n = int(input())
s = input()
Xs = s.count('X')
xs = s.count('x')
change = abs(Xs - xs) // 2
if Xs > xs:
	s = s.replace('X', 'x', change)
else:
	s = s.replace('x', 'X', change)
print(change)
print(s)


def list_to_str(a):
	y = ''
	for i in range(len(a)):
		y = y + str(a[i])
	return y
n = int(input())
s = input()

def chrnum(s, a):
	ans = 0
	for i in s:
		if i == a:
			ans += 1
	return ans
a = chrnum(s, 'X')
b = len(s) - a
c = int(abs(a - b) / 2)
print(c)
s = list(s)

def fn(s, c):
	if a > b:
		for i in range(n):
			if s[i] == 'X':
				s[i] = 'x'
				c -= 1
			if c == 0:
				return list_to_str(s)
	elif a < b:
		for i in range(n):
			if s[i] == 'x':
				s[i] = 'X'
				c -= 1
			if c == 0:
				return list_to_str(s)
	else:
		return list_to_str(s)
print(fn(s, c))


(z, zz) = (input, lambda : list(map(int, z().split())))
fast = lambda : stdin.readline().strip()
zzz = lambda : [int(i) for i in fast().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = 1
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
n = int(z())
arr = fast()
one = arr.count('X')
zerr = arr.count('x')
if one > zerr:
	print(one - n // 2)
	t = arr.replace('X', 'x', one - n // 2)
	print(t)
else:
	t = arr.replace('x', 'X', zerr - n // 2)
	print(zerr - n // 2)
	print(t)


n = int(input())
s = input()
stoya = 0
stoyaa = []
for i in range(n):
	if s[i] == 'X':
		stoya = stoya + 1
		stoyaa.append(i)
i = 0
j = 0
if stoya < n / 2:
	razn = n / 2 - stoya
	while razn > 0:
		if not i in stoyaa:
			razn = razn - 1
			s = s[0:i] + 'X' + s[i + 1:n]
			j = j + 1
		i = i + 1
if stoya > n / 2:
	razn = stoya - n / 2
	while razn > 0:
		if i in stoyaa:
			razn = razn - 1
			s = s[0:i] + 'x' + s[i + 1:n]
			j = j + 1
		i = i + 1
print(j)
print(s)


n = int(input())
s = list(input())
i = 0
j = 0
scx = s.count('x')
scxb = s.count('X')
if scx < scxb:
	while i < (scxb - scx) // 2:
		if s[j] == 'X':
			s[j] = s[j].lower()
			i += 1
		j += 1
	print(i)
	print(''.join((c for c in s)))
elif scx > scxb:
	while i < (scx - scxb) // 2:
		if s[j] == 'x':
			s[j] = s[j].upper()
			i += 1
		j += 1
	print(i)
	print(''.join((c for c in s)))
else:
	print(0)
	print(''.join((c for c in s)))


n = int(input())
k = input()
total = k.count('x')
minutes = abs(total - n // 2)
if total > n // 2:
	k = k.replace('x', 'X', minutes)
elif total < n // 2:
	k = k.replace('X', 'x', minutes)
print('{}\n{}'.format(minutes, k))


n = int(input())
m = input()[:n]
a = int(n / 2)
(c1, c2) = (0, 0)
for i in range(n):
	if m[i] == 'x':
		c1 += 1
	else:
		c2 += 1
if c1 == c2 == a:
	print(0)
	print(m)
elif c1 > c2:
	print(c1 - a)
	m = m.replace('x', 'X', c1 - a)
	print(m)
else:
	print(c2 - a)
	m = m.replace('X', 'x', c2 - a)
	print(m)


y = input()
x = input()
list = []
for letter in x:
	list.append(letter)
a = list.count('x')
b = list.count('X')
count = 0
if a > b:
	i = 0
	while a > b:
		if list[i] != 'X':
			list[i] = 'X'
			count += 1
		i += 1
		a = list.count('x')
		b = list.count('X')
if a < b:
	i = 0
	while a < b:
		if list[i] != 'x':
			list[i] = 'x'
			count += 1
		i += 1
		a = list.count('x')
		b = list.count('X')
string = ''
for item in list:
	string = string + item
print(count)
print(string)


n = int(input())
l = list(input())
Xx = (l.count('X') - l.count('x')) // 2
ans = 0
if Xx > 0:
	for i in range(n):
		if Xx == 0:
			break
		if l[i] == 'X':
			l[i] = 'x'
			Xx -= 1
			ans += 1
else:
	for i in range(n):
		if Xx == 0:
			break
		if l[i] == 'x':
			l[i] = 'X'
			Xx += 1
			ans += 1
print(ans)
print(''.join(map(str, l)))


import math
a = int(input())
y = input()
smallxc = 0
result = ''
for i in range(0, a):
	if y[i:i + 1] == 'x':
		smallxc += 1
if smallxc == a // 2:
	print(0)
	print(y)
else:
	counter = 0
	if smallxc > a // 2:
		for j in range(0, a):
			if y[j:j + 1] == 'x':
				result += 'X'
				counter += 1
				if counter == smallxc - a // 2:
					break
			else:
				result += 'X'
		result += y[j + 1:]
	else:
		for j in range(0, a):
			if y[j:j + 1] == 'X':
				result += 'x'
				counter += 1
				if counter == a // 2 - smallxc:
					break
			else:
				result += 'x'
		result += y[j + 1:]
	print(abs(smallxc - a // 2))
	print(result)


n = int(input())
s = input()
result = ''
a = s.count('X')
b = s.count('x')
print(abs(a - b) // 2)
if a >= b:
	for i in s:
		if i == 'X' and a != n // 2:
			result += 'x'
			a -= 1
		else:
			result += i
else:
	for i in s:
		if i == 'x' and b != n // 2:
			result += 'X'
			b -= 1
		else:
			result += i
print(result)


n = int(input())
s = input()
cnt_x = s.count('x')
minutes = abs(cnt_x - n // 2)
ans = list(s)
if cnt_x < n // 2:
	i = 0
	j = 0
	while i < minutes and j < n:
		if ans[j] == 'X':
			ans[j] = 'x'
			i += 1
		j += 1
elif cnt_x > n // 2:
	i = 0
	j = 0
	while i < minutes and j < n:
		if ans[j] == 'x':
			ans[j] = 'X'
			i += 1
		j += 1
print(minutes)
print(''.join(ans))


n = int(input())
s = list(str(input()))
cnt = 0
for i in s:
	if i == 'x':
		cnt += 1
print(int(abs(cnt - n / 2)))
if cnt < n / 2:
	for i in range(0, n):
		if s[i] == 'X' and cnt < n / 2:
			s[i] = 'x'
			cnt += 1
else:
	for i in range(0, n):
		if s[i] == 'x' and cnt > n / 2:
			s[i] = 'X'
			cnt -= 1
print(''.join(s))


n = int(input()) // 2
s = input()
x = s.count('x')
print(abs(x - n))
if x < n:
	print(s.replace('X', 'x', n - x))
elif x > n:
	print(s.replace('x', 'X', x - n))
else:
	print(s)


n = int(input())
st = list(input())
a = st.count('X')
b = st.count('x')
if a == n // 2:
	print('0')
	print(''.join(st))
elif a > n // 2:
	count = 0
	while count < abs(a - n // 2):
		for i in range(len(st)):
			if st[i] == 'X':
				st[i] = 'x'
				break
		count += 1
	print(abs(a - n // 2))
	print(''.join(st))
else:
	count = 0
	while count < abs(b - n // 2):
		for i in range(len(st)):
			if st[i] == 'x':
				st[i] = 'X'
				break
		count += 1
	print(abs(a - n // 2))
	print(''.join(st))


n = int(input())
x = list(input())
st = x.count('X')
if st == n / 2:
	print(0)
	print(''.join(x))
elif st > n / 2:
	count = st - n / 2
	while count > 0:
		index = x.index('X')
		x[index] = 'x'
		count -= 1
	print(int(abs(st - n / 2)))
	print(''.join(x))
else:
	count = abs(st - n / 2)
	while count > 0:
		index = x.index('x')
		x[index] = 'X'
		count -= 1
	print(int(abs(st - n / 2)))
	print(''.join(x))


from itertools import *

def read_ints():
	return map(int, input().strip().split())
(n,) = read_ints()
x = input().strip()
sit = 0
for c in x:
	if c == 'x':
		sit += 1
standup = sit - n // 2
copy = standup
newstr = ['']
for c in x:
	if c == 'x' and standup > 0:
		newstr.append('X')
		standup -= 1
	elif c == 'X' and standup < 0:
		newstr.append('x')
		standup += 1
	else:
		newstr.append(c)
print(abs(copy))
print(''.join(newstr))


n = int(input())
line = list(input())
stand = 0
for m in line:
	if m.isupper():
		stand += 1
if stand > n // 2:
	d = stand - n // 2
	for i in range(n):
		if d > 0:
			if line[i].isupper():
				line[i] = line[i].lower()
				d -= 1
		else:
			break
elif stand < n // 2:
	d = n // 2 - stand
	for i in range(n):
		if d > 0:
			if line[i].islower():
				line[i] = line[i].upper()
				d -= 1
		else:
			break
print(abs(stand - n // 2))
print(''.join(line))


n = int(input())
arr = input()
sit = 0
stand = 0
for i in arr:
	if i == 'x':
		sit += 1
	else:
		stand += 1
if sit == stand:
	print(0)
	print(arr)
elif sit < stand:
	print(int(n / 2) - sit)
	temp = list(arr)
	changed = 0
	for i in range(n):
		if changed == int(n / 2) - sit:
			break
		if arr[i] == 'X':
			temp[i] = 'x'
			changed += 1
	print(''.join(temp))
else:
	print(int(n / 2) - stand)
	temp = list(arr)
	changed = 0
	for i in range(n):
		if changed == int(n / 2) - stand:
			break
		if arr[i] == 'x':
			temp[i] = 'X'
			changed += 1
	print(''.join(temp))


n = int(input())
hams = input()
print(abs(hams.count('x') - n // 2))
print(hams.replace('x', 'X', max(0, hams.count('x') - n // 2)).replace('X', 'x', max(0, hams.count('X') - n // 2)))


(n, t) = (int(input()), input())
(a, b) = ('x', 'X')
k = t.count(a) - n // 2
if k:
	t = list(t)
	if k < 0:
		(a, b, k) = (b, a, -k)
	print(k)
	for (i, c) in enumerate(t):
		if c == a:
			t[i] = b
			k -= 1
			if k == 0:
				break
	print(''.join(t))
else:
	print('0\n' + t)


n = int(input())
s = input()
l = list(s)
x = []
X = []
(a, b) = (0, 0)
for i in range(n):
	if l[i] == 'x':
		a += 1
		x.append(i)
	else:
		b += 1
		X.append(i)
if a > b:
	t = int(n / 2) - b
	ans1 = t
	for i in x:
		if t > 0:
			l[i] = 'X'
			t -= 1
elif b > a:
	t = int(n / 2) - a
	ans1 = t
	for i in X:
		if t > 0:
			l[i] = 'x'
			t -= 1
ans = ''
for i in range(n):
	ans += l[i]
if a == b:
	print(0)
	print(ans)
else:
	print(ans1)
	print(ans)


z = int(input())
x = list(map(str, input()))
if x.count('X') >= x.count('x'):
	print(z // 2 - x.count('x'))
	b = 'x'
	a = 'X'
else:
	print(z // 2 - x.count('X'))
	b = 'X'
	a = 'x'
for i in range(z // 2 - x.count(b)):
	x[x.index(a)] = b
print(''.join(x))


n = int(input(''))
y = input('')
k = 0
w = ''
for ham in y:
	if ham == 'X':
		k = k + 1
x = int(n / 2 - k)
x1 = abs(x)
newlist = []
for ham in y:
	newlist.append(ham)
if x < 0:
	x = abs(x)
	for ham in newlist:
		if ham == 'X' and x != 0:
			newlist[newlist.index(ham)] = 'x'
			x = x - 1
if x > 0:
	for ham in newlist:
		if ham == 'x' and x != 0:
			newlist[newlist.index(ham)] = 'X'
			x = x - 1
for items in newlist:
	w = w + items
print(x1)
print(w)


n = int(input())
s = input()
(f, t) = ('x', 'X')
c = n // 2 - s.count(t)
if c < 0:
	(f, t) = (t, f)
	c = -c
print(c)
for ch in s:
	if ch == f and c > 0:
		print(t, end='')
		c -= 1
	else:
		print(ch, end='')


(n, s_list) = (int(input()), list(input()))
cnt = 0
a_list = [[s_list.count('X'), 'X'], [s_list.count('x'), 'x']]
while a_list[0][0] != a_list[1][0]:
	a_list.sort()
	s_list[s_list.index(a_list[1][1])] = a_list[0][1]
	a_list[1][0] -= 1
	a_list[0][0] += 1
	cnt += 1
print(cnt)
print(''.join(s_list))


n = int(input())
s = input()
count = s.count('x')
res = int(abs(count - (n - count)) / 2)
print(res)
i = 0
ss = ''
if count > n - count:
	while res != 0:
		if s[i] == 'X':
			ss += s[i]
		else:
			ss += 'X'
			res -= 1
		i += 1
else:
	while res != 0:
		if s[i] == 'x':
			ss += s[i]
		else:
			ss += 'x'
			res -= 1
		i += 1
print(ss + s[i:])


n = int(input())
s = input()
Min = min(abs(n // 2 - s.count('X')), abs(n // 2 - s.count('x')))
print(Min)
print(s.replace('X', 'x', Min) if s.count('X') >= s.count('x') else s.replace('x', 'X', Min))


n = int(input())
s = input()
if s.count('X') == n / 2:
	print(0)
	print(s)
elif s.count('X') > n / 2:
	count = s.count('X') - n / 2
	count1 = 0
	for i in s:
		if i == 'X':
			s = s.replace(i, 'x', 1)
			count1 += 1
		if count1 == count:
			print(int(count))
			print(s)
			quit()
else:
	count = n / 2 - s.count('X')
	count1 = 0
	for i in s:
		if i == 'x':
			s = s.replace(i, 'X', 1)
			count1 += 1
		if count1 == count:
			print(int(count))
			print(s)
			quit()


n = int(input())
string = input()
new_string = ''
s = string.count('X')
d = string.count('x')
if s == d:
	print(0)
	print(string)
	exit()
k = max(s, d)
if s == k:
	temp = k - n / 2
	print(int(temp))
	for ch in string:
		if ch == 'X' and temp > 0:
			new_string += 'x'
			temp -= 1
			continue
		new_string += ch
else:
	temp = k - n / 2
	print(int(temp))
	for ch in string:
		if ch == 'x' and temp > 0:
			new_string += 'X'
			temp -= 1
			continue
		new_string += ch
print(new_string)


input()
X = input()
(Stand, Sit) = (X.count('X'), X.count('x'))
Dif = (max(Stand, Sit) - min(Stand, Sit)) // 2
print(Dif)
print(X.replace('X', 'x', Dif) if Stand >= Sit else X.replace('x', 'X', Dif), sep='\n')


n = int(input())
str = input()
sit = 0
for i in str:
	if i == 'x':
		sit += 1
minutes = abs(n / 2 - sit)
result = ''
if minutes == 0:
	result = str
else:
	if sit >= n / 2:
		s = 'X'
	else:
		s = 'x'
	l = minutes
	for i in str:
		t = i
		if t != s and l > 0:
			t = s
			l -= 1
		result += t
print('%d' % minutes)
print(result)


n = int(input())
c = 0
s = input()
p = list(s)
numsit = s.count('x')
i = 0
while numsit != n // 2:
	if p[i] == 'x' and numsit > n // 2:
		numsit -= 1
		p[i] = 'X'
		c += 1
	elif p[i] == 'X' and numsit < n // 2:
		numsit += 1
		p[i] = 'x'
		c += 1
	i += 1
print(c)
print(''.join(p))


n = int(input())
s = list(input())
cnt = s.count('x')
ans = cnt - n // 2
if ans > 0:
	tmp = ans
	for (i, x) in enumerate(s):
		if x == 'x':
			s[i] = 'X'
			tmp -= 1
			if tmp == 0:
				break
elif ans < 0:
	ans = -ans
	tmp = ans
	for (i, x) in enumerate(s):
		if x == 'X':
			s[i] = 'x'
			tmp -= 1
			if tmp == 0:
				break
print(ans)
print(''.join(s))


n = int(input())
s = list(input())
a = s.count('X')
b = s.count('x')
y = []
y.append(a)
y.append(b)
i = 0
j = 0
if a < b:
	o = 'X'
	l = 'x'
else:
	o = 'x'
	l = 'X'
while i < abs(n // 2 - y[0]) and j < len(s):
	if s[j] == l:
		s[j] = o
		i += 1
	j += 1
print(abs(n // 2 - y[0]))
print(''.join(s))


def solve():
	n = int(input())
	s = list(input())
	c = ''
	if s.count('x') < s.count('X'):
		c = 'x'
	else:
		c = 'X'
	print(int(abs(s.count('x') - s.count('X')) / 2))
	for i in range(0, n):
		if s.count(c) == n / 2:
			break
		if s[i] != c:
			s[i] = c
	print(*s, sep='')
solve()


n = int(input())
s = input()
a = s.count('x')
b = s.count('X')
if a > b:
	print(n // 2 - b)
	print(s.replace('x', 'X', n // 2 - b))
elif b > a:
	print(n // 2 - a)
	print(s.replace('X', 'x', n // 2 - a))
else:
	print(0)
	print(s)


numero = int(input())
estados = str(input())
parados = 0
sentados = 0
separados = []
contador = 0
for i in estados:
	separados.append(i)
	if i == 'X':
		parados += 1
	elif i == 'x':
		sentados += 1
total = len(estados)
if parados > sentados:
	resultado = total // 2 - sentados
	for i in range(len(separados)):
		if separados[i] == 'X':
			contador += 1
			separados[i] = 'x'
		if contador == resultado:
			break
elif sentados > parados:
	resultado = total // 2 - parados
	for i in range(len(separados)):
		if separados[i] == 'x':
			contador += 1
			separados[i] = 'X'
		if contador == resultado:
			break
else:
	resultado = 0
print(resultado)
print(''.join(separados))


num = int(input())
s = input()
dif = abs(s.count('x') - s.count('X')) // 2
if s.count('x') > s.count('X'):
	s = s.replace('x', 'X', dif)
else:
	s = s.replace('X', 'x', dif)
print(dif)
print(s)


import string
sol = 0
n = input()
cnt_sit = 0
cnt_stand = 0
si = 0
st = 0
string = input()
for i in string:
	if i.isupper() == True:
		cnt_stand += 1
	else:
		cnt_sit += 1
if cnt_sit == int(n) / 2 and cnt_stand == int(n) / 2:
	print(0)
	print(string)
elif cnt_sit > cnt_stand:
	while cnt_sit != int(n) / 2 and cnt_stand != int(n) / 2:
		si += 1
		cnt_sit -= 1
		cnt_stand += 1
		sol += 1
	print(sol)
	for i in string:
		if i.islower() == True and si != 0:
			print(i.upper(), end='')
			si -= 1
		else:
			print(i, end='')
	print(' ')
else:
	while cnt_sit != int(n) / 2 and cnt_stand != int(n) / 2:
		st += 1
		cnt_sit += 1
		cnt_stand -= 1
		sol += 1
	print(sol)
	for i in string:
		if i.isupper() == True and st != 0:
			print(i.lower(), end='')
			st -= 1
		else:
			print(i, end='')
	print(' ')


def squats(n, h_string):
	counts = [0, 0]
	h_list = list(h_string)
	for i in range(0, n):
		if h_string[i] == 'x':
			counts[0] += 1
		else:
			counts[1] += 1
	steps = counts[0] - counts[1]
	if steps > 0:
		counter = 0
		for i in range(0, n):
			if h_list[i] == 'x':
				h_list[i] = 'X'
				counter += 2
				if counter == abs(steps):
					break
	elif steps < 0:
		counter = 0
		for i in range(0, n):
			if h_list[i] == 'X':
				h_list[i] = 'x'
				counter += 2
				if counter == abs(steps):
					break
	return (abs(steps) // 2, ''.join(h_list))
n = int(input())
h_string = input()
(a, b) = squats(n, h_string)
print(a)
print(b)


n = int(input())
s = input()
diff = (s.count('x') - s.count('X')) // 2
print(abs(diff))
s = list(s)
for i in range(n):
	if diff > 0 and s[i] == 'x':
		s[i] = 'X'
		diff -= 1
	elif diff < 0 and s[i] == 'X':
		s[i] = 'x'
		diff += 1
print(''.join(s))


class CodeforcesTask424ASolution:

	def __init__(self):
		self.result = ''
		self.n = 0
		self.state = ''

	def read_input(self):
		self.n = int(input())
		self.state = input()

	def process_task(self):
		to = self.n // 2 - min(self.state.count('x'), self.state.count('X'))
		a = 'x' if self.state.count('x') < self.state.count('X') else 'X'
		b = 'x' if self.state.count('x') > self.state.count('X') else 'X'
		x = to
		while x:
			x -= 1
			self.state = self.state.replace(b, a, 1)
		self.result = str(to) + '\n' + self.state

	def get_result(self):
		return self.result
Solution = CodeforcesTask424ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


n = int(input())
a = input()
t = a.count('X')
c = n // 2
if t == c:
	print('0')
	print(a)
elif t < c:
	print(c - t)
	a = a.replace('x', 'X', c - t)
	print(a)
else:
	print(t - c)
	a = a.replace('X', 'x', t - c)
	print(a)


n = int(input())
s = input().strip()
cntx = 0
cntX = 0
for i in range(n):
	if s[i] == 'x':
		cntx += 1
cntX = n - cntx
if cntx > n // 2:
	c = cntx - n // 2
	print(c)
	for i in range(n):
		if s[i] == 'x' and c > 0:
			print('X', end='')
			c -= 1
		else:
			print(s[i], end='')
else:
	c = cntX - n // 2
	print(c)
	for i in range(n):
		if s[i] == 'X' and c > 0:
			print('x', end='')
			c -= 1
		else:
			print(s[i], end='')


ham = int(input())
pos = str(input())
sit = int(0)
up = int(0)
sitr = int(0)
mov = int(0)
prit = str('')
for z in pos:
	if z == 'x':
		sit = int(sit + 1)
	if z == 'X':
		up = int(up + 1)
sitr = int(ham / 2)
if sitr != sit:
	if sitr > sit:
		mov = int(sitr - sit)
		print(mov)
		for x in pos:
			if x == 'x':
				prit = str(prit + 'x')
			elif x == 'X' and mov > 0:
				mov = int(mov - 1)
				prit = str(prit + 'x')
			elif x == 'X' and mov == 0:
				prit = str(prit + 'X')
		print(prit)
	elif sitr < sit:
		mov = int(sit - sitr)
		print(mov)
		for x in pos:
			if x == 'x' and mov > 0:
				mov = int(mov - 1)
				prit = str(prit + 'X')
			elif x == 'x' and mov == 0:
				prit = str(prit + 'x')
			elif x == 'X':
				prit = str(prit + 'X')
		print(prit)
elif sitr == sit:
	print('0')
	print(pos)


input()
s = input()
c1 = s.count('x')
c2 = s.count('X')
if c1 > c2:
	s = s.replace('x', 'X', max(0, (c1 - c2) // 2))
else:
	s = s.replace('X', 'x', max(0, (c2 - c1) // 2))
print(abs(c2 - c1) // 2)
print(s)


n = int(input())
a = list(input())
(up, down) = (0, 0)
for i in range(len(a)):
	if a[i] == 'X':
		up += 1
	else:
		down += 1
if down == up:
	print(0)
	print(''.join(a))
else:
	x = abs(up - down) // 2
	tmp = 0
	if up > down:
		for i in range(len(a)):
			if tmp == x:
				break
			if a[i] == 'X':
				a[i] = 'x'
				tmp += 1
		print(x)
		print(''.join(a))
	else:
		for i in range(len(a)):
			if tmp == x:
				break
			if a[i] == 'x':
				a[i] = 'X'
				tmp += 1
		print(x)
		print(''.join(a))


n = int(input())
global s
s = input()
(a, b) = (s.count('x'), s.count('X'))
p = abs(a - b) // 2

def change(a, b):
	global s
	q = 0
	for x in range(n):
		if q == p:
			break
		if s[x] == a:
			s = s[:x] + b + s[x + 1:]
			q += 1
print(p)
if a > b:
	change('x', 'X')
else:
	change('X', 'x')
print(s)


def solve(s):
	u = 0
	d = 0
	for c in s:
		if c == 'X':
			u += 1
		else:
			d += 1
	res = abs(d - u) // 2
	s = list(s)
	i = 0
	while res > 0:
		if s[i] == 'x' and d > u:
			s[i] = 'X'
			res -= 1
		elif s[i] == 'X' and u > d:
			s[i] = 'x'
			res -= 1
		i += 1
	print(abs(d - u) // 2)
	print(''.join(s))

def main():
	n = int(input())
	s = input()
	solve(s)
main()


n = int(input())
t = input()
sit = t.count('x')
up = n - sit
if sit > up:
	print(sit - n // 2)
	print(t.replace('x', 'X', sit - n // 2))
elif up > sit:
	print(up - n // 2)
	print(t.replace('X', 'x', up - n // 2))
else:
	print(0)
	print(t)


n = int(input())
a = list(input())
z = a.count('X')
p = n // 2
print(abs(p - z))
if z > p:
	t = 0
	for i in range(n):
		if t < abs(p - z):
			if a[i] == 'X':
				a[i] = 'x'
				t += 1
		else:
			break
	for i in range(n):
		print(a[i], end='')
elif z == p:
	for i in range(n):
		print(a[i], end='')
else:
	t = 0
	for i in range(n):
		if t < abs(p - z):
			if a[i] == 'x':
				a[i] = 'X'
				t += 1
		else:
			break
	for i in range(n):
		print(a[i], end='')


n = input()
n = int(n)
y = input()
x_s = 0
x_c = 0
b = ''
for i in range(n):
	if y[i] == 'x':
		x_s += 1
	else:
		x_c += 1
if x_s == x_c:
	print(0)
	for i in y:
		print(i, end='')
if x_s > x_c:
	u = n / 2 - x_c
	o = n / 2 - x_c
	while u > 0:
		for i in range(n):
			if y[i] == 'x' and (not u < 1):
				b += 'X'
				u -= 1
			else:
				b += y[i]
	print(int(o))
	for i in b:
		print(i, end='')
if x_s < x_c:
	u = n / 2 - x_s
	o = n / 2 - x_s
	while u > 0:
		for i in range(n):
			if y[i] == 'X' and (not u < 1):
				b += 'x'
				u -= 1
			else:
				b += y[i]
	print(int(o))
	for i in b:
		print(i, end='')


n = int(input())
s = input()
ans = []
for i in range(n):
	ans.append(s[i])
x = s.count('x')
X = n - x
cnt = 0
if x > X:
	i = 0
	while X < x:
		if s[i] == 'x':
			ans[i] = 'X'
			X += 1
			x -= 1
			cnt += 1
		i += 1
elif X > x:
	i = 0
	while x < X:
		if s[i] == 'X':
			ans[i] = 'x'
			x += 1
			X -= 1
			cnt += 1
		i += 1
print(cnt)
for i in range(n):
	print(ans[i], end='')


input()
inp = input()
n = len(inp)
stand = inp.count('X')
sit = inp.count('x')
if stand > sit:
	diff = stand - n // 2
	res = inp.replace('X', 'x', diff)
else:
	diff = sit - n // 2
	res = inp.replace('x', 'X', diff)
print(diff)
print(res)


n = int(input())
s = input()
x = s.count('x')
y = s.count('X')
z = n // 2 - min(x, y)
if min(x, y) != x:
	s = s.replace('x', 'X', z)
else:
	s = s.replace('X', 'x', z)
print(z)
print(s)


import sys
n = int(sys.stdin.readline())
ni = sys.stdin.readline()
nh = 0
nl = 0
for i in range(n):
	if ni[i] == 'X':
		nh += 1
	else:
		nl += 1
t = []
c = 0
if nl > nh:
	k = int(n / 2) - nh
	for i in range(n):
		if ni[i] == 'x' and k > 0:
			c += 1
			t.append('X')
			k -= 1
		else:
			t.append(ni[i])
elif nh > nl:
	k = int(n / 2) - nl
	for i in range(n):
		if ni[i] == 'X' and k > 0:
			c += 1
			t.append('x')
			k -= 1
		else:
			t.append(ni[i])
elif nh == nl:
	print(0)
	print(ni)
	exit()
print(c)
print(''.join(t))


n = int(input())
s = input()
(X, x) = (s.count('X'), s.count('x'))
result = n // 2 - min(X, x)
s = s.replace('X', 'x', result) if X > x else s.replace('x', 'X', result)
print(result)
print(s)


def main(n, s):
	stand = len(list(filter(lambda i: i == 'X', s)))
	dif = max(n // 2, stand) - min(n // 2, stand)
	r = 0
	if stand > n // 2:
		r ^= 1
	print(dif)
	for i in range(n):
		if dif <= 0:
			break
		if r == 0 and s[i] == 'x':
			s[i] = 'X'
			dif -= 1
		elif r == 1 and s[i] == 'X':
			s[i] = 'x'
			dif -= 1
	return ''.join(s)
print(main(int(input()), list(input())))


n = int(input())
s = input()
X = 0
x = 0
for i in s:
	if i == 'x':
		x += 1
	else:
		X += 1
print(abs(x - X) // 2)
if x == X:
	print(s)
elif x > X:
	for i in s:
		if i == 'x' and x > X:
			print('X', end='')
			x -= 1
			X += 1
		else:
			print(i, end='')
else:
	for i in s:
		if i == 'X' and X > x:
			print('x', end='')
			X -= 1
			x += 1
		else:
			print(i, end='')


n = int(input())
s = input()
a = s.count('x')
b = s.count('X')
print(abs(a - b) // 2)
print(('X' if a > b else 'x').join(s.split('x' if a > b else 'X', abs(a - b) // 2)))


n = int(input())
a = input()
s = list(a)
b = 0
c = 0
d = n // 2
for i in range(n):
	if a[i] == 'x':
		b += 1
	else:
		c += 1
if b == c:
	print(0)
	print(a)
else:
	if b < d:
		print(d - b)
		for i in range(len(s)):
			if s[i] == 'X' and b < d:
				s[i] = 'x'
				b += 1
	elif c < d:
		print(d - c)
		for i in range(len(s)):
			if s[i] == 'x' and c < d:
				s[i] = 'X'
				c += 1
	ans = ''
	for i in range(n):
		ans += s[i]
	print(ans)


n = int(input())
positions = list(input())
needed = n // 2
standing = 0
for i in range(n):
	if positions[i] == 'X':
		standing += 1
print(abs(needed - standing))
i = 0
while needed > standing:
	if positions[i] == 'x':
		positions[i] = 'X'
		standing += 1
	i += 1
i = 0
while needed < standing:
	if positions[i] == 'X':
		positions[i] = 'x'
		needed += 1
	i += 1
print(''.join(positions))


n = int(input())
s = input()
x1 = s.count('X')
x = s.count('x')
if x1 == n // 2:
	print(0)
	print(s)
elif x1 > n // 2:
	print(x1 - n // 2)
	s = s.replace('X', 'x', x1 - n // 2)
	print(s)
else:
	print(x - n // 2)
	s = s.replace('x', 'X', x - n // 2)
	print(s)


n = int(input())
hamsters = list(input())
count = 0
for i in range(n):
	if hamsters.count('x') == n // 2:
		break
	if hamsters.count('x') > n // 2:
		if hamsters[i] == 'x':
			count += 1
			hamsters[i] = 'X'
	elif hamsters[i] == 'X':
		count += 1
		hamsters[i] = 'x'
print(count)
print(''.join(hamsters))


n = int(input())
s = input()
numX = s.count('X')
if numX < n // 2:
	print(n // 2 - numX)
	print(str.replace(s, 'x', 'X', n // 2 - numX))
else:
	print(numX - n // 2)
	print(str.replace(s, 'X', 'x', numX - n // 2))


n = int(input())
s = list(input())
x = 0
X = 0
for c in s:
	if c == 'x':
		x += 1
	else:
		X += 1
if x == n / 2:
	print(0)
elif X > x:
	c = (X - x) // 2
	print(c)
	for i in range(n):
		if s[i] == 'X':
			s[i] = 'x'
			c -= 1
			if c == 0:
				break
else:
	c = (x - X) // 2
	print(c)
	for i in range(n):
		if s[i] == 'x':
			s[i] = 'X'
			c -= 1
			if c == 0:
				break
print(''.join(s))


n = int(input())
st = input()
cO = 0
co = 0
for i in st:
	if i == 'x':
		co += 1
	else:
		cO += 1
if co == cO:
	print(0)
	print(st)
else:
	l1 = list(st)
	if co > cO:
		print(co - n // 2)
		n1 = co - n // 2
		while n1 != 0:
			for j in range(len(l1)):
				if l1[j] == 'x':
					l1[j] = 'X'
					n1 -= 1
					break
		print(*l1, sep='')
	else:
		print(cO - n // 2)
		n1 = cO - n // 2
		while n1 != 0:
			for j in range(len(l1)):
				if l1[j] == 'X':
					l1[j] = 'x'
					n1 -= 1
					break
		print(*l1, sep='')


n = int(input())
li = list(input())
a = li.count('x')
b = li.count('X')
check = ''
check1 = ''
a1 = 0
if a > b:
	a1 = a - n // 2
	check = 'x'
	check1 = 'X'
elif b > a:
	a1 = b - n // 2
	check = 'X'
	check1 = 'x'
else:
	print(0)
	print(''.join(li))
	exit(0)
b2 = a1
for i in range(len(li)):
	if a1 > 0 and li[i] == check:
		li[i] = check1
		a1 -= 1
print(b2)
print(''.join(li))


n = int(input(''))
m = list(input(''))
count = 0
for i in range(n):
	if m[i] == 'X':
		count += 1
if n / 2 == count:
	print('0')
	for i in range(n):
		print(m[i], end='')
if n / 2 > count:
	print(int(n / 2 - count))
	k = n / 2 - count
	for i in range(n):
		if m[i] == 'x' and k > 0:
			print('X', end='')
			k -= 1
		else:
			print(m[i], end='')
if n / 2 < count:
	print(int(count - n / 2))
	k = count - n / 2
	for i in range(n):
		if m[i] == 'X' and k > 0:
			print('x', end='')
			k -= 1
		else:
			print(m[i], end='')


n = int(input())
s = list(input())
sit = 0
for i in range(n):
	if s[i] == 'x':
		sit += 1
ans = 0
i = 0
while i < n and sit < n - sit:
	if s[i] == 'X':
		sit += 1
		ans += 1
		s[i] = 'x'
	i += 1
i = 0
while i < n and sit > n - sit:
	if s[i] == 'x':
		sit -= 1
		ans += 1
		s[i] = 'X'
	i += 1
print(ans)
print(''.join(s))


num = int(input())
ham = input()
ham1 = ''
stand = 0
sit = 0
minute = 0
for i in range(len(ham)):
	if 'X' == ham[i]:
		stand += 1
sit = len(ham) - stand
if stand == sit:
	minute = 0
elif stand > len(ham) // 2:
	minute = stand - len(ham) // 2
	j = 0
	for i in range(len(ham)):
		if ham[i] == 'X' and j < minute:
			ham1 = ham1 + 'x'
			j += 1
		else:
			ham1 += ham[i]
elif sit > len(ham) // 2:
	minute = sit - len(ham) // 2
	j = 0
	for i in range(len(ham)):
		if ham[i] == 'x' and j < minute:
			ham1 = ham1 + 'X'
			j += 1
		else:
			ham1 += ham[i]
if minute == 0:
	print(minute)
	print(ham)
else:
	print(minute)
	print(ham1)


n = int(input())
s = list(input())
x = s.count('x')
b = n // 2 - min(x, n - x)
if n - x == x:
	t = ''
elif n - x > x:
	t = 'X'
else:
	t = 'x'
print(b)
for i in range(n):
	if s[i] == t:
		b -= 1
		s[i] = 'x' if t == 'X' else 'X'
	if b == 0:
		break
print(''.join(s))


import re
import inspect
from sys import argv, exit

def rstr():
	return input()

def rint():
	return int(input())

def rints(splitchar=' '):
	return [int(i) for i in input().split(splitchar)]

def varnames(obj, namespace=globals()):
	return [name for name in namespace if namespace[name] is obj]

def pvar(var, override=False):
	prnt(varnames(var), var)

def prnt(*args, override=False):
	if '-v' in argv or override:
		print(*args)
n = rint()
ham = rstr()
ham = [1 if x == 'X' else 0 for x in ham]
sham = sum(ham)
if sham > n / 2:
	to_change = sham - n / 2
	for (i, x) in enumerate(ham):
		if x == 1:
			ham[i] = 0
			to_change -= 1
			if not to_change:
				break
	print(int(sham - n / 2))
	print(''.join(['X' if x else 'x' for x in ham]))
elif sham < n / 2:
	to_change = n / 2 - sham
	for (i, x) in enumerate(ham):
		if x == 0:
			ham[i] = 1
			to_change -= 1
			if not to_change:
				break
	print(int(n / 2 - sham))
	print(''.join(['X' if x else 'x' for x in ham]))
else:
	print(int(n / 2 - sham))
	print(''.join(['X' if x else 'x' for x in ham]))


bot = True
input()
s = input()
c1 = s.count('x')
c2 = s.count('X')
s = s.replace('x', 'X', max(0, (c1 - c2) // 2))
s = s.replace('X', 'x', max(0, (c2 - c1) // 2))
print(abs(c2 - c1) // 2)
print(s)


n = int(input())
s = input()
x1 = s.count('x')
x2 = s.count('X')
x3 = (max(x1, x2) - min(x1, x2)) // 2
i = 0
print(x3)
if x1 > x2:
	while s.count('x') != s.count('X'):
		if s[i] == 'x':
			s = s[:i] + 'X' + s[i + 1:]
		i += 1
elif x2 > x1:
	while s.count('x') != s.count('X'):
		if s[i] == 'X':
			s = s[:i] + 'x' + s[i + 1:]
		i += 1
print(s)


a = int(input())
b = input()
c = b.count('x')
d = b.count('X')
e = abs(a // 2 - d)
f = abs(a // 2 - c)
if d == a // 2:
	print(0)
	print(b)
elif d < a // 2:
	print(e)
	print(b.replace('x', 'X', e))
elif c < a // 2:
	print(f)
	print(b.replace('X', 'x', f))


n = int(input()) // 2
l1 = list(input())
const = l1.count('x') - l1.count('X')
ans = 0
while l1.count('X') - l1.count('x') != 0:
	if l1.count('X') > l1.count('x'):
		l1[l1.index('X')] = 'x'
	else:
		l1[l1.index('x')] = 'X'
	ans += 1
print(ans)
print(''.join(l1))


n = int(input())
s = input()
k = s.count('X')
k1 = n - k
p = int(abs(k - k1) / 2)
s1 = ''
if k >= k1:
	for i in s:
		if i == 'X' and k != k1:
			s1 += 'x'
			k -= 1
			k1 += 1
		else:
			s1 += i
if k < k1:
	for i in s:
		if i == 'x' and k != k1:
			s1 += 'X'
			k += 1
			k1 -= 1
		else:
			s1 += i
print(p)
print(s1)


def main():
	n = int(input())
	state = [c for c in input()]
	n_stand_ups = state.count('X')
	n_sit_downs = n - n_stand_ups
	count = abs(n_stand_ups - n_sit_downs) // 2
	index = -1
	if n_sit_downs > n_stand_ups:
		for _ in range(count):
			index = next((i for i in range(index + 1, n) if state[i] == 'x'))
			state[index] = 'X'
	else:
		for _ in range(count):
			index = next((i for i in range(index + 1, n) if state[i] == 'X'))
			state[index] = 'x'
	print(count)
	print(''.join(state))
main()


n = int(input())
s = input()
s
x = s.count('x')
X = s.count('X')
rs = int(abs(x - X) / 2)
if x > X:
	t = 'x'
	T = 'X'
else:
	t = 'X'
	T = 'x'
temp = ''
for i in range(len(s)):
	if s[i] == t:
		if rs:
			rs -= 1
		else:
			temp += s[i:len(s)]
			break
		temp += T
	else:
		temp += s[i]
rs = int(abs(x - X) / 2)
print(rs)
print(temp)


import sys

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

def iinput():
	return int(input())

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

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
n = iinput()
a = input()
c = a.count('X')
if c == n // 2:
	print(0)
	print(a)
else:
	if c > n // 2:
		a = a.replace('X', 'x', c - n // 2)
	else:
		a = a.replace('x', 'X', n // 2 - c)
	print(abs(c - n // 2))
	print(a)


n = int(input())
ls = input()
val = abs(ls.count('X') - ls.count('x')) / 2
print(int(val))
if val != 0:
	ch = 'X' if ls.count('X') < ls.count('x') else 'x'
	nstr = ''
	for i in ls:
		if val > 0:
			if i != ch:
				nstr += ch
				val -= 1
			else:
				nstr += ch
		else:
			nstr += i
	print(nstr)
else:
	print(ls)


n = int(input())
st = input()
l1 = list(st)
small = st.count('x')
cap = st.count('X')
diff = 0
if cap == small:
	print(0)
	print(st)
elif cap < small:
	diff = (small - cap) // 2
	temp = 0
	for i in range(n):
		if l1[i] == 'x' and temp < diff:
			l1[i] = 'X'
			temp += 1
	print(diff)
	print(''.join(l1))
else:
	diff = (cap - small) // 2
	temp = 0
	for i in range(n):
		if l1[i] == 'X' and temp < diff:
			l1[i] = 'x'
			temp += 1
	print(diff)
	print(''.join(l1))