Andrewid the Android is a galaxy-famous detective. In his free time he likes to think about strings containing zeros and ones.

Once he thought about a string of length n consisting of zeroes and ones. Consider the following operation: we choose any two adjacent positions in the string, and if one them contains 0, and the other contains 1, then we are allowed to remove these two digits from the string, obtaining a string of length n - 2 as a result.

Now Andreid thinks about what is the minimum length of the string that can remain after applying the described operation several times (possibly, zero)? Help him to calculate this number.


-----Input-----

First line of the input contains a single integer n (1 ≤ n ≤ 2·10^5), the length of the string that Andreid has.

The second line contains the string of length n consisting only from zeros and ones.


-----Output-----

Output the minimum length of the string that may remain after applying the described operations several times.


-----Examples-----
Input
4
1100

Output
0

Input
5
01010

Output
1

Input
8
11101111

Output
6



-----Note-----

In the first sample test it is possible to change the string like the following: $1100 \rightarrow 10 \rightarrow(\text{empty})$.

In the second sample test it is possible to change the string like the following: $01010 \rightarrow 010 \rightarrow 0$.

In the third sample test it is possible to change the string like the following: $11101111 \rightarrow 111111$.

Difficulty: EASY

Solutions:
n = int(input())
s = input()
(o, z, i) = (0, 0, 0)
while i < n:
	if s[i] == '0':
		z += 1
	else:
		o += 1
	i += 1
print(abs(z - o))


length = int(input())
n = input()
ones = n.count('1')
print(abs(2 * ones - length))


n = int(input())
string = input()
ones = string.count('1')
zeros = string.count('0')
pairs = min(ones, zeros)
print(n - 2 * pairs)


a = input()
b = input()
z = b.count('1')
c = b.count('0')
n = abs(z - c)
print(n)


n = int(input())
s = input()
digits = list(map(int, s))
c1 = 0
c0 = 0
for i in digits:
	if i == 0:
		c0 += 1
	else:
		c1 += 1
print(n - 2 * min(c0, c1))


n = int(input())
a = list(map(int, input()))
z = 0
o = 0
for i in range(n):
	if a[i] == 0:
		z += 1
	else:
		o += 1
if z > o:
	print(z - o)
elif o > z:
	print(o - z)
else:
	print(z - o)


n = int(input())
m = input()
one = m.count('1')
zero = m.count('0')
union = min(one, zero)
print(max(one - union, zero - union))


a = int(input())
b = input()
one = b.count('1')
zero = b.count('0')
union = min(one, zero)
if one > zero:
	print(one - union)
elif zero > one:
	print(zero - union)
else:
	print(0)


length = int(input())
number = input()
l1 = []
for num in number:
	l1.append(num)
if l1.count('0') == l1.count('1'):
	print(0)
else:
	print(abs(l1.count('0') - l1.count('1')))


n = int(input())
s = input()
a = []
b = []
for i in s:
	if i == '0':
		a.append(i)
	else:
		b.append(i)
res = abs(len(a) - len(b))
print(res)


def main():
	input()
	binario = input()
	print(abs(binario.count('1') - binario.count('0')))
main()


a = int(input())
b = input()
c = b.count('1')
d = b.count('0')
f = 0
if c > d:
	f = c - d
elif c < d:
	f = d - c
print(f)


n = int(input())
s = input()
ones = s.count('1')
zeroes = s.count('0')
print(n - 2 * min(ones, zeroes))


n = int(input())
a = input()
q = a.count('1') - a.count('0')
if q < 0:
	q *= -1
print(q)


n = int(input())
s = input()
a = s.count('0')
b = s.count('1')
print(max(a, b) - min(a, b))


a = int(input())
b = str(input())
c = b.count('1')
i = c * 2
d = a - i
if d < 0:
	print(d * -1)
else:
	print(d)


def main():
	n = int(input())
	q = list(input())
	zero = q.count('0')
	ones = q.count('1')
	print(abs(zero - ones))
main()


from collections import Counter
input()
s = input()
f = Counter(s)
print(abs(f['0'] - f['1']))


n = int(input())
s = input()
a = 0
b = 0
for i in s:
	if i == '0':
		a += 1
	else:
		b += 1
print(abs(a - b))


x = int(input())
k = input()
s = [int(n) for n in k]
a = s.count(0)
b = s.count(1)
print(abs(a - b))


n = int(input())
s = input()
a = s.count('1')
B = s.count('0')
print(abs(a - B))


inputs = [input() for _ in range(2)]
x = 0
for i in inputs[1]:
	if i == '1':
		x += 1
	else:
		x -= 1
print(abs(x))


n = int(input())
s = input()
o = 0
z = 0
for i in s:
	if i == '0':
		o = o + 1
	else:
		z = z + 1
if o == z:
	print(0)
if z > o:
	print(z - o)
if z < o:
	print(o - z)


n = int(input())
s = input()
(one, zero) = (0, 0)
for item in s:
	if item == '1':
		one += 1
	elif item == '0':
		zero += 1
count = 0
if one > zero:
	count = one - zero
else:
	count = zero - one
print(count)


from collections import Counter
input()
occ = Counter(list(input())).most_common()
if len(occ) == 1:
	print(occ[0][1])
else:
	print(occ[0][1] - occ[1][1])


n = int(input())
x = str(input())
stack = []
res = 0
for i in range(len(x)):
	if len(stack) and stack[-1] != x[i]:
		res += 1
		stack.pop()
	else:
		stack.append(x[i])
print(len(stack))


n = int(input())
inp = input()
ones = 0
zeros = 0
for item in inp:
	if item == '1':
		ones += 1
	else:
		zeros += 1
print(abs(ones - zeros))


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as c
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

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

def out(var):
	sys.stdout.write(str(var))

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

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
n = int(data())
s = data()
outln(abs(s.count('1') - s.count('0')))


tamanho = int(input())
t = input()
posicao = 0
cont1 = 0
cont0 = 0
for x in t:
	if x == '1':
		cont1 = cont1 + 1
	elif x == '0':
		cont0 = cont0 + 1
while cont1 > 0 and cont0 > 0:
	cont0 = cont0 - 1
	cont1 = cont1 - 1
	tamanho = tamanho - 2
print(tamanho)


a = int(input())
a = input()
s = []
for i in a:
	if s:
		if s[-1] == '0' and i == '1' or (s[-1] == '1' and i == '0'):
			s.pop()
		else:
			s.append(i)
	else:
		s.append(i)
print(len(s))


def min(a, b):
	if a < b:
		return a
	else:
		return b
n = int(input())
arr = list(input())
cnt_1 = 0
cnt_0 = 0
for i in range(n):
	if arr[i] == '1':
		cnt_1 += 1
	else:
		cnt_0 += 1
n = n - 2 * min(cnt_0, cnt_1)
print(n)


n = int(input())
s = input()
d = 0
for c in s:
	if c == '0':
		d += 1
	else:
		d -= 1
print(abs(d))


n = int(input())
s = str(input())
print(n - 2 * min(s.count('1'), s.count('0')))


n = int(input())
s = input()
a = 0
b = 0
for i in range(0, n):
	if s[i] == '0':
		a = a + 1
	else:
		b = b + 1
if a > b:
	print(n - 2 * b)
else:
	print(n - 2 * a)


n = int(input())
num = input()
c0 = 0
c1 = 0
for d in num:
	if d == '0':
		c0 += 1
	else:
		c1 += 1
print(abs(c0 - c1))


n = int(input())
s = '2' + str(input()) + '2'
zero = s.count('0')
one = s.count('1')
print(n - 2 * min(zero, one))


n = int(input())
a = list(input())
b = sum((1 for c in a if c == '1'))
print(abs(n - 2 * b))


b = int(input())
a = str(input())
c = a.count('1')
d = a.count('0')
g = min(c, d)
print(b - g * 2)


def solve(s):
	s = list(map(int, list(s)))
	stack = []
	for i in s:
		stack.append(i)
		if len(stack) >= 2:
			if stack[-1] == 0 and stack[-2] == 1 or (stack[-1] == 1 and stack[-2] == 0):
				stack.pop()
				stack.pop()
	return len(stack)

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


n = int(input())
a = input()
print(abs(a.count('0') - a.count('1')))


from collections import Counter
n = int(input())
s = input()
d = Counter(s)
if len(d) == 1:
	ans = n
else:
	m = min(d.values())
	ans = n - 2 * m
print(ans)


n = int(input())
A = [int(i) for i in input()]
print(n - 2 * min(A.count(0), A.count(1)))


n = int(input())
s = input()
a = 0
for _ in s:
	if _ == '1':
		a += 1
	else:
		a -= 1
if a < 0:
	a = a * -1
print(a)


n = int(input())
arr = input()
onec = 0
zeroc = 0
for i in range(0, n):
	if arr[i] is '0':
		zeroc += 1
	else:
		onec += 1
print(abs(zeroc - onec))


n = input()
string = input()
i = 0
d = {'0': 0, '1': 0}
for i in string:
	d[i] = d[i] + 1
print(abs(d['0'] - d['1']))


n = int(input())
s = input()
a = s.count('0')
b = n - a
if a == b:
	print(0)
else:
	c = min(a, b)
	print(n - 2 * c)


n = int(input())
s = input()
zeros = 0
ones = 0
for f in range(n):
	if s[f] == '0':
		zeros = zeros + 1
	else:
		ones = ones + 1
ans = ones if zeros > ones else zeros
print(n - 2 * ans)


n = input()
n = int(n)
a = input()
a = list(a)
zero = 0
one = 0
for i in a:
	if i == '0':
		zero += 1
	else:
		one += 1
print(max(zero, one) - min(zero, one))


n = int(input())
s = input()
oneCount = 0
zeroCount = 0
for i in s:
	if i == '0':
		zeroCount += 1
	elif i == '1':
		oneCount += 1
if oneCount > zeroCount:
	print(oneCount - zeroCount)
else:
	print(zeroCount - oneCount)


input()
string = input()
a = string.count('0')
b = string.count('1')
print(abs(a - b))


input()
a = input()
print(abs(a.count('0') - a.count('1')))


n = int(input())
(c, d) = (0, 0)
m = input()
for i in m:
	if i == '0':
		c += 1
	elif i == '1':
		d += 1
print(abs(d - c))


num = int(input())
st = input()
zero = one = 0
for i in st:
	if i == '1':
		one += 1
	else:
		zero += 1
m = min(one, zero)
print(num - 2 * m)


a = int(input())
l = list(input())
d = l.count('1')
e = l.count('0')
f = abs(d - e)
print(f)


a = int(input())
s = input()
if s.count('0') > s.count('1'):
	print(s.count('0') - s.count('1'))
else:
	print(s.count('1') - s.count('0'))


n = int(input())
s = input()
a = []
for x in s:
	if len(a) and a[-1] != x:
		a.pop()
	else:
		a.append(x)
print(len(a))


from collections import defaultdict

def solve(x):
	res = defaultdict(int)
	for i in str(x):
		res[i] += 1
	a = res['0']
	b = res['1']
	return abs(a - b)
(n, *_) = tuple(map(int, input().split()))
(x, *_) = list(map(str, input().split()))
print(solve(x))


z = int(input())
x = input()
a = x.count('0')
b = x.count('1')
print(abs(a - b))


n = int(input())
s = input().strip()
l = []
for a in s:
	if not l:
		l.append(a)
	elif a != l[-1]:
		l.pop()
	else:
		l.append(a)
print(len(l))


n = int(input())
s = input()
c0 = s.count('0')
c1 = s.count('1')
print(n - min(c0, c1) * 2)


n = int(input())
l = input()
x = l.count('1')
if x > n - x:
	print(n - 2 * (n - x))
else:
	print(n - 2 * x)


n = int(input())
s = input()
s = list(s)
x = s.count('1')
y = s.count('0')
count = 0
if x == y:
	count = len(s) - x * 2
elif x > y:
	count = len(s) - y * 2
elif x < y:
	count = len(s) - x * 2
print(count)


g = int(input())
n = str(input())
b = 0
f = 0
for i in n:
	if i == '1':
		b = b + 1
	elif i == '0':
		f = f + 1
	else:
		b = b + 0
		f = f + 0
print(len(n) - 2 * min(b, f))


import math
a = int(input())
str = str(input())
c = str.count('1')
print(abs(2 * c - a))


n = int(input())
string = input()
num_one = 0
num_zero = 0
for x in string:
	if x == '1':
		num_one += 1
	elif x == '0':
		num_zero += 1
print(abs(num_one - num_zero))


from sys import stdin, stdout
n = int(stdin.readline().strip())
s = stdin.readline().strip()
stk = []
ind = 0
while ind < n:
	stk.append(s[ind])
	while len(stk) >= 2 and stk[-1] != stk[-2]:
		stk.pop()
		stk.pop()
	ind += 1
print(len(stk))


n = int(input())
s = input()
oc = s.count('1')
zc = s.count('0')
if oc > zc:
	print(oc - zc)
elif oc < zc:
	print(zc - oc)
else:
	print(0)


input()
s = input()
print(abs(len(s) - 2 * s.count('0')))


s = []
input()
st = input()
for num in st:
	if s and num != s[-1]:
		s.pop()
	else:
		s.append(num)
print(len(s))


import math, fractions
n = int(input())
s = str(input())
c0 = s.count('0')
c1 = s.count('1')
if c0 == c1:
	print(0)
else:
	print(len(s) - 2 * min(s.count('0'), s.count('1')))


input()
n = input()
if n.count('1') >= n.count('0'):
	print(n.count('1') - n.count('0'))
else:
	print(n.count('0') - n.count('1'))


m = int(input())
n = list(map(int, input()))
print(len(n) - 2 * min(n.count(0), n.count(1)))


input()
main_str = input()
a1 = main_str.count('1')
a0 = main_str.count('0')
if a1 >= a0:
	print(a1 - a0)
else:
	print(a0 - a1)


n = int(input())
zeros = input().count('0')
print(abs(n - zeros * 2))


a = int(input())
b = input()
c = b.count('0')
d = b.count('1')
while c >= 1 and d >= 1:
	c = c - 1
	d = d - 1
	a = a - 2
print(a)


n = int(input())
string = input()
print(n - 2 * min(string.count('1'), string.count('0')))


n = int(input())
s = input()
count = 0
for i in range(len(s)):
	if s[i] == '0':
		count = count + 1
one = n - count
print(abs(count - one))


n = int(input())
binary = list(input())
numOnes = 0
numZeros = 0
for x in range(0, n):
	if binary[x] == '1':
		numOnes += 1
	else:
		numZeros += 1
result = numOnes - numZeros
if result < 0:
	result *= -1
print(result)


n = int(input())
word = input()
m = word.count('1')
a = abs(n - 2 * m)
print(a)


def solve(n, num):
	nz = n1 = 0
	for i in range(0, n):
		if num[i] == '0':
			nz += 1
		else:
			n1 += 1
	return abs(nz - n1)
n = int(input())
num = input()
print(solve(n, num))


n = int(input())
stng = input()
zeros = 0
ones = 0
for i in stng:
	if i == '1':
		ones += 1
	else:
		zeros += 1
print(abs(zeros - ones))


n = int(input())
s = input()
ones = s.count('1')
print(n - 2 * min(ones, n - ones))


x = int(input())
y = input()
z = list(y)
a = 0
b = 0
for i in y:
	if i == '1':
		a += 1
	else:
		b += 1
print(abs(a - b))


cnt1 = 0
cnt2 = 0
n = int(input())
st = input()
for i in range(len(st)):
	if st[i] == '1':
		cnt1 += 1
	else:
		cnt2 += 1
if cnt1 == cnt2:
	print(0)
elif cnt1 < cnt2:
	print(len(st) - 2 * cnt1)
else:
	print(len(st) - 2 * cnt2)


import math
leng = int(input())
text = input()
zeroes = 0
ones = 0
for i in text:
	if int(i) == 0:
		zeroes += 1
	else:
		ones += 1
print(int(math.fabs(zeroes - ones)))


n = input()
x = str(input())
print(abs(x.count('0') - x.count('1')))


(n,) = map(int, input().split())
s = input()
print(n - 2 * min(len(s.replace('1', '')), len(s.replace('0', ''))))


from collections import deque
D = deque()
l = int(input())
s = input()
D.append(s[0])
for i in range(1, l):
	if len(D) != 0:
		t = D.pop()
		if not (s[i] == '0' and t == '1') and (not (s[i] == '1' and t == '0')):
			D.append(t)
			D.append(s[i])
	else:
		D.append(s[i])
print(len(D))


def main():
	input()
	s = input()
	one = 0
	zero = 0
	for ch in s:
		if ch == '0':
			one += 1
		else:
			zero += 1
	print(abs(one - zero))

def __starting_point():
	main()
__starting_point()


n = input()
arr = input()
ones = 0
twos = 0
for i in arr:
	if i == '1':
		ones = ones + 1
	else:
		twos = twos + 1
print(abs(ones - twos))


n = int(input())
s = input()
num = s.count('1')
num2 = s.count('0')
print(max(num2, num) - min(num2, num))


(n, s) = (int(input()), input())
print(abs(s.count('0') - s.count('1')))


n = int(input())
str = input()
ones = str.count('1')
print(abs(ones - (n - ones)))


_ = input()
s = input()
print(abs(s.count('1') - s.count('0')))


n = int(input())
s = input()
count0 = 0
count1 = 0
for i in range(n):
	if s[i] == '1':
		count1 += 1
	else:
		count0 += 1
print(max(count1, count0) - min(count0, count1))


n = int(input())
s = input()
list = []
for c in s:
	list.append(int(c))
p = []
for c in s:
	if p == []:
		p.append(c)
	elif c == '0' and p[-1] == '0':
		p.append(c)
	elif c == '0' and p[-1] == '1':
		p.pop(-1)
	elif c == '1' and p[-1] == '0':
		p.pop(-1)
	elif c == '1' and p[-1] == '1':
		p.append(c)
print(len(p))


a = int(input())
b = input()
c = b.count('1')
d = b.count('0')
print(abs(c - d))


n = int(input())
s = input()
o = z = 0
for c in s:
	if c == '1':
		o += 1
	else:
		z += 1
print(abs(o - z))


n = int(input())
s = input()
x = s.count('1')
y = s.count('0')
print(abs(x - y))


elem = int(input())
s = input()
zero = 0
one = 0
for i in range(len(s)):
	if s[i] == '0':
		zero = zero + 1
	else:
		one = one + 1
print(abs(one - zero))


input()
a = list(input())
k = a.count('1')
r = a.count('0')
print(k + r - 2 * min(k, r))


n = int(input())
s = list(str(input()))
print(abs(s.count('0') - s.count('1')))


n = int(input())
a = list(input())
x = a.count('1')
y = a.count('0')
print(abs(x - y))


n = int(input())
l = input()
n = 0
for e in l:
	n += (int(e) << 1) - 1
print(abs(n))


string_len = int(input())
string = input()
print(abs(string.count('1') - string.count('0')))


n = int(input())
s = input()
a = s.count('1')
b = s.count('0')
print(n - min(a, b) * 2)


n = int(input())
ipt = input()
counter = 0
for var in ipt:
	if var == '1':
		counter += 1
	else:
		counter -= 1
print(abs(counter))


n = int(input())
a = list(str(input()))
x = a.count('1')
y = a.count('0')
print(n - 2 * min(x, y))


from collections import deque
length = int(input())
string = input()
stack = deque()
last_in = None
for number in string:
	if len(stack) == 0 or number == last_in:
		stack.append(number)
		last_in = number
	elif len(stack) > 0:
		stack.pop()
print(len(stack))


def countF(a, s):
	return sum((1 for j in s if j == a))
n = int(input())
s = input()
print(abs(countF('0', s) - countF('1', s)))


n = int(input())
s = input()
c1 = 0
c2 = 0
for i in range(n):
	if s[i] == '1':
		c1 += 1
	else:
		c2 += 1
print(abs(c1 - c2))


input()
x = input()
a = x.count('1')
b = x.count('0')
print(max(a, b) - min(a, b))


input()
s = []
for i in input():
	if s and s[-1] != i:
		s.pop()
	else:
		s += (i,)
print(len(s))


n = int(input())
sequence = str(input())
count_zero = len(sequence.replace('1', ''))
count_one = len(sequence.replace('0', ''))
if count_one > count_zero:
	result = count_one - count_zero
else:
	result = count_zero - count_one
print(result)


n = int(input())
num = input()
ones = num.count('1')
zeros = num.count('0')
print(abs(ones - zeros))


n = int(input())
s = input()
s = list(s)
l = s.count('1')
k = s.count('0')
if l >= k:
	print(l - k)
else:
	print(k - l)


__author__ = 'artyom'

def main():
	n = read()
	z = 0
	for v in read(0):
		if v == '0':
			z += 1
	return n - 2 * (z if z <= n // 2 else n - z)

def read(mode=1, size=None):
	if mode == 0:
		return input().strip()
	if mode == 1:
		return int(input().strip())
	if mode == 2:
		return input().strip().split()
	if mode == 3:
		return list(map(int, input().strip().split()))
	a = []
	for _ in range(size):
		a.append(read(3))
	return a

def write(s='\n'):
	if s is None:
		s = ''
	if isinstance(s, tuple) or isinstance(s, list):
		s = ' '.join(map(str, s))
	s = str(s)
	print(s, end='\n')
res = main()
write(res)


(n, c) = (int(input()), 0)
for x in list(map(int, input())):
	c += 2 * x - 1
print(c * (2 * int(c >= 0) - 1))


n = int(input())
s = input()
(count0, count1) = (0, 0)
for i in range(n):
	if s[i] == '0':
		count0 += 1
	else:
		count1 += 1
print(str(n - 2 * min(count0, count1)))


n = int(input())
s = [i for i in input()]
o = 0
z = 0
for i in range(n):
	if s[i] == '0':
		z += 1
	else:
		o += 1
print(n - min(o, z) * 2)


length = int(input())
string = input()
zeros = string.count('0')
ones = string.count('1')
print(length - 2 * min(zeros, ones))


n = int(input())
s = input()
n0 = 0
n1 = 0
ans = n
for i in range(n):
	if s[i] == '0':
		if n1 > 0:
			n1 -= 1
			ans -= 2
		else:
			n0 += 1
	elif n0 > 0:
		n0 -= 1
		ans -= 2
	else:
		n1 += 1
print(ans)


import math
n = int(input())
s = input()
print(abs(s.count('1') - s.count('0')))


import math
import os
import random
import re
import sys
m = int(input())
s = str(input())
print(abs(s.count('1') - s.count('0')))


n1 = int(input())
n = input()
l = []
for i in range(0, n1):
	if len(l) == 0:
		l.append(n[i])
	elif n[i] == '1':
		if l[-1] == '0':
			l.pop()
		else:
			l.append(n[i])
	elif n[i] == '0':
		if l[-1] == '1':
			l.pop()
		else:
			l.append(n[i])
print(len(l))


n = int(input())
m = input()
a = m.count('0')
b = m.count('1')
print(abs(a - b))


print(abs(int(input()) - 2 * input().count('1')))


n = int(input())
string = input()
original_string = str(string)
string_stack = []
count = 0
if n:
	string_stack.append(string[0])
for i in range(1, len(string)):
	if string_stack and string_stack[-1] != string[i]:
		del string_stack[-1]
	else:
		string_stack.append(string[i])
print(len(string_stack))


n = int(input())
line = input()
print(abs(line.count('1') - line.count('0')))


(n, s, last) = (int(input()), input(), 0)
stack = [s[0]]
for i in range(1, n):
	if len(stack) > 0 and stack[-1] != s[i]:
		stack.pop()
	else:
		stack.append(s[i])
print(len(stack))


n = int(input())
s = input()
one = s.count('1')
print(abs(n - 2 * one))


t = int(input())
n = input()
count0 = 0
count1 = 0
for i in range(0, t):
	if n[i] == '0':
		count0 += 1
	else:
		count1 += 1
count0 = min(count0, count1)
print(t - 2 * count0)


_ = input()
text = input()
print(abs(text.count('0') - text.count('1')))


n = int(input())
linha = input()
uns = 0
zeros = 0
for e in linha:
	if e == '1':
		uns += 1
	else:
		zeros += 1
ans = abs(zeros - uns)
print(ans)


n = int(input())
a = input()
l = list(a)
o = l.count('1')
z = l.count('0')
if z == 0 or o == 0:
	print(n)
elif o < z:
	print(n - 2 * o)
else:
	print(n - 2 * z)


n = int(input())
A = list(input())
a = A.count('1')
b = A.count('0')
print(abs(a - b))


input()
l = input()
print(abs(l.count('0') - l.count('1')))


from sys import stdin

def r():
	return stdin.readline().strip()

def r_t(tp):
	return map(tp, r().strip().split())

def r_a(tp):
	return list(r_t(tp))

def solve(n, t):
	(zeros, ones) = (0, 0)
	for x in t:
		if x == '1':
			ones += 1
		else:
			zeros += 1
	return abs(zeros - ones)

def main():
	n = int(r())
	t = r()
	print(solve(n, t))
main()


n = int(input())
string = input()
ones = string.count('0')
twos = string.count('1')
print(abs(ones - twos))


n = int(input())
L = list(input())
print(abs(L.count('0') - L.count('1')))


try:
	input()
	l = list(input())
	stack = []
	for e in l:
		if len(stack) > 0 and e == '0' and (stack[-1] == '1'):
			stack.pop()
		elif len(stack) > 0 and e == '1' and (stack[-1] == '0'):
			stack.pop()
		else:
			stack.append(e)
	print(len(stack))
except:
	pass


n = int(input())
a = list(map(int, input()))
d = []
for i in range(len(a)):
	d.append(a[i])
	while len(d) >= 2 and d[-1] + d[-2] == 1:
		d.pop()
		d.pop()
		n -= 2
print(n)


x = input()
x = input()
t1 = x.count('1')
t2 = x.count('0')
if t1 > t2:
	print(len(x) - t2 * 2)
else:
	print(len(x) - t1 * 2)


n = int(input())
l = input()
a = l.count('1')
b = l.count('0')
print(abs(a - b))


inp = input()
n = int(inp)
inp = input()
n_zeros = 0
n_ones = 0
ans = 0
last_char = -1
for c in inp:
	if c == '1':
		n_ones = n_ones + 1
	elif c == '0':
		n_zeros = n_zeros + 1
print(n - 2 * min(n_ones, n_zeros))


import functools
input().strip()
s = input().strip()
(z, u) = functools.reduce(lambda acc, x: (acc[0] + 1, acc[1]) if x == '0' else (acc[0], acc[1] + 1), s, (0, 0))
print(abs(z - u))


n = int(input())
s = input()
cnt_0 = 0
cnt_1 = 0
for i in range(n):
	if s[i] == '1':
		cnt_1 += 1
	elif s[i] == '0':
		cnt_0 += 1
c = min(cnt_0, cnt_1)
print(n - 2 * c)


n = input()
x = str(input())
zero = x.count('0')
one = x.count('1')
mini = min(zero, one)
zero -= mini
one -= mini
print(zero + one)


n = int(input())
s = list(input())
(s0, s1) = (0, 0)
for i in range(n):
	if s[i] == '1':
		s1 += 1
	else:
		s0 += 1
temp = min(s0, s1)
print(n - temp * 2)


n = int(input())
l = input()
print(l.count('0') + l.count('1') - 2 * min(l.count('0'), l.count('1')))


n = input()
a = input()
b = []
for i in range(int(n)):
	b.append(int(a[i]))
countOnes = 0
countZeros = 0
for i in range(len(b)):
	if b[i] == 0:
		countZeros += 1
	else:
		countOnes += 1
if countOnes == countZeros:
	print(0)
elif countOnes > countZeros:
	print(countOnes - countZeros)
else:
	print(countZeros - countOnes)


import time
n = int(input())
s = [i for i in input()]
start = time.time()
flag = 1
sum0 = sum([1 for i in s if i == '0'])
sum1 = n - sum0
m = min(sum0, sum1)
print(n - 2 * m)
finish = time.time()


n = int(input())
l = list(map(int, list(input())))
(x, y) = (sum(l), n - sum(l))
print(abs(x - y))


a = int(input())
b = list(map(int, input()))
x = b.count(0)
y = b.count(1)
print(abs(x - y))


n = int(input())
s = input()
l = list(s)
l = list(map(int, s))
c = 0
for i in range(n):
	if l[i] == 1:
		c += 1
print(abs(n - c - c))


n = int(input())
a = str(input())
b = a.count('0')
c = len(a) - 2 * min(len(a) - b, b)
print(c)


n = int(input())
str = input()
print(len(str) - min(str.count('0'), str.count('1')) * 2)


n = int(input())
x = list(input())
y = ' '.join(x)
z = y.replace('0', '-1')
m = [int(i) for i in z.split()]
c = m[0]
l = len(m)
for i in range(1, l):
	if c > 0 and m[i] < 0 or (c < 0 and m[i] > 0):
		l -= 2
	c += m[i]
print(l)


n = int(input())
print(abs(n - 2 * sum([int(x) for x in input()])))


n = int(input())
s = input()
o = []
z = []
for i in s:
	if i == '0':
		z.append(int(i))
	else:
		o.append(int(i))
if len(z) == len(o):
	print(len(z) - len(o))
if len(z) > len(o):
	print(len(z) - len(o))
if len(z) < len(o):
	print(len(o) - len(z))


size = input()
string = input()
zero = string.count('0')
one = string.count('1')
print(abs(zero - one))


input()
string = input()
print(abs(string.count('1') - string.count('0')))


n = int(input())
s = input()
count_1 = s.count('1')
count_0 = s.count('0')
print(abs(count_0 - count_1))


import sys
n = input()
s = input()
print(abs(s.count('0') - s.count('1')))


n = int(input())
s = input()
c1 = s.count('1')
c2 = s.count('0')
print(abs(c1 - c2))


import sys

def solve():
	(n,) = rv()
	a = list(map(int, list(input())))
	print(abs(a.count(0) - a.count(1)))

def prt(l):
	return print(' '.join(l))

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

def rl(n):
	return [list(map(int, input().split())) for _ in range(n)]
if sys.hexversion == 50594544:
	sys.stdin = open('test.txt')
solve()


a = int(input())
b = input()
n1 = b.count('1')
n0 = b.count('0')
print(abs(n1 - n0))


n = int(input())
s = input()
count0 = 0
count1 = 0
for i in range(len(s)):
	if s[i] == '1':
		count1 += 1
	else:
		count0 += 1
print(abs(count1 - count0))


a = int(input())
n = list(input())
n1 = n0 = 0
for i in range(a):
	if n[i] == '1':
		n1 += 1
	else:
		n0 += 1
print(abs(n0 - n1))


(n, z) = (int(input()), input().count('0'))
print(abs(2 * z - n))


import math
import sys
import string

def ri():
	return input()

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

def li():
	return input().split()

def mi():
	return list(map(int, input().split()))
n = ii()
a = ri()
z = 0
o = 0
for i in a:
	if i == '0':
		z += 1
	else:
		o += 1
print(abs(z - o))


input()
import collections
s = input()
c = collections.Counter(s)
print(abs(c['1'] - c['0']))


n = int(input())
k = input()
a = k.count('0')
b = k.count('1')
print(abs(a - b))


tam = int(input())
palavra = input()
zeros = 0
uns = 0
for letra in palavra:
	if letra == '0':
		zeros += 1
	else:
		uns += 1
resp = tam - 2 * min(zeros, uns)
print(resp)


n = int(input())
number = input()
print(n - 2 * min(number.count('0'), number.count('1')))


def polycarp():
	x = int(input())
	y = input()
	print(abs(y.count('1') - y.count('0')))
polycarp()


def zeros_eyes(s):
	(count1, count2) = (0, 0)
	for i in range(len(s)):
		if s[i] == '0':
			count1 += 1
		else:
			count2 += 1
	return abs(count1 - count2)
n = int(input())
print(zeros_eyes(input()))


n = int(input())
t = list(input())
x = t.count('1')
y = t.count('0')
if x > y:
	print(len(t) - y * 2)
elif x < y:
	print(len(t) - x * 2)
else:
	print('0')


n = int(input())
s = input()
c0 = 0
c1 = 0
for i in range(n):
	if s[i] == '1':
		c1 = c1 + 1
	else:
		c0 = c0 + 1
print(max(c1, c0) - min(c1, c0))


n = int(input())
s = input()
a = s.count('0')
b = s.count('1')
if a >= b:
	c = a - b
	print(c)
else:
	c = b - a
	print(c)


a = input()
b = input()

def m(n):
	if n == 0:
		return 0
	if n > 0:
		return n
	else:
		return -n
z = b.count('1')
d = b.count('0')
print(m(z - d))


__author__ = 'Andrey'
n = int(input())
num = input()
stack = []
for char in num:
	if len(stack) == 0:
		stack.append(char)
	elif char != stack[-1]:
		stack.pop()
	else:
		stack.append(char)
print(len(stack))


n = int(input())
word = input()
res = abs(word.count('1') - word.count('0'))
print(res)


n = int(input())
s = input()
print(len(s) - 2 * min(s.count('0'), s.count('1')))


A = int(input())
B = input()
C = B.count('0')
D = B.count('1')
if C > D:
	E = C - D
	print(A - D * 2)
if C < D:
	E = D - C
	print(A - C * 2)
if C == D:
	print('0')


from sys import stdout
num = input()
x = input()
a = x.count('0')
b = x.count('1')
out = abs(a - b)
stdout.write(str(out))


tamanho = int(input())
linha = input()
zero = 0
um = 0
for i in range(tamanho):
	if linha[i] == '1':
		um += 1
	if linha[i] == '0':
		zero += 1
resto = 0
total = 0
if zero > um:
	resto = zero - um
if um > zero:
	resto = um - zero
total = zero + um - resto
print(tamanho - total)


import sys
import math
import bisect
import re

def main():
	n = int(input())
	one = 0
	zero = 0
	for c in input():
		if c == '1':
			one += 1
		elif c == '0':
			zero += 1
	ans = max(one, zero) - min(one, zero)
	print(ans)
main()


n = int(input())
word = input()
zero = 0
one = 0
for i in range(0, n):
	if word[i] == '1':
		one += 1
	else:
		zero += 1
print(abs(one - zero))


n = int(input())
s = input()
o = 0
e = 0
for i in s:
	if i == '0':
		o += 1
	else:
		e += 1
print(abs(o - e))


n = int(input())
s = input()
a = []
for i in range(n):
	if a and a[-1] != s[i]:
		a.pop()
	else:
		a.append(s[i])
print(len(a))


def zeroAndOne(x, n):
	oneNum = 0
	zeroNum = 0
	for i in range(len(n)):
		if n[i] == '1':
			oneNum += 1
		elif n[i] == '0':
			zeroNum += 1
	return oneNum - zeroNum
x = int(input())
n = input()
answer = zeroAndOne(x, n)
print(abs(answer))


n = int(input())
s = input()
o = s.count('1')
z = s.count('0')
p = min(o, z)
print(n - 2 * p)


n = int(input())
s = input()
zeros = 0
ones = 0
for x in s:
	if x == '0':
		zeros += 1
	else:
		ones += 1
print(n - min(zeros, ones) * 2)


n = input()
s = input()
ans = abs(s.count('0') - s.count('1'))
print(ans)


inp = int(input())
s = input()
(zero, one) = (0, 0)
for num in s:
	if num == '1':
		one += 1
	else:
		zero += 1
print(abs(zero - one))


k = int(input())
a = input()
b = 0
e = 0
n = 0
for i in range(k):
	if a[i] == '1':
		e += 1
	else:
		n += 1
if e > n:
	b = e - n
elif n > e:
	b = n - e
elif n == e:
	b = 0
print(b)


n = int(input())
a = input()
c = 0
for i in a:
	if i == '0':
		c += 1
	else:
		c -= 1
print(abs(c))


n = int(input())
data = list(input())
print(n - 2 * min(data.count('0'), data.count('1')))


t = int(input())
s = input()
print(abs(s.count('0') - s.count('1')))


n = input('')
n = int(n)
st = input('')
a = str(st)
m = 0
for i in range(n):
	if a[i] == '1':
		m += 1
print(abs(n - 2 * m))


l = int(input())
num = str(input())
a = []
for n in num:
	if len(a) == 0:
		a.append(n)
	elif n != a[-1]:
		a.pop()
	else:
		a.append(n)
print(len(a))


n = int(input())
s = input()
ones = s.count('1')
zeros = s.count('0')
print(n - 2 * min(ones, zeros))


n = int(input())
s = input()
o = s.count('0')
z = s.count('1')
print(abs(z - o))


n = int(input().strip())
s = input().strip()
print(abs(n - s.count('1') * 2))


length = int(input())
num = str(input())
print(abs(num.count('0') - num.count('1')))


entrada = int(input())
seq = input()
zero = 0
um = 0
for e in seq:
	if e == '1':
		um += 1
	elif e == '0':
		zero += 1
print(abs(zero - um))


n = int(input())
s = input()
o = s.count('1')
c = min(o, n - o) * 2
print(n - c)


a = int(input())
b = input()
zero = 0
one = 0
for i in b:
	if i == '0':
		zero += 1
	else:
		one += 1
if zero < one:
	print(a - 2 * zero)
else:
	print(a - 2 * one)


n = int(input())
line = list(input())
num1 = line.count('0')
num0 = line.count('1')
print(abs(num1 - num0))


N = int(input())
S = input()
count1 = 0
count0 = 0
for i in range(N):
	if S[i] == '0':
		count0 += 1
	if S[i] == '1':
		count1 += 1
print(abs(count0 - count1))


n = int(input())
oz = str(input())
one = oz.count('1')
zero = oz.count('0')
if zero > one:
	print(n - one * 2)
elif zero < one:
	print(n - zero * 2)
else:
	print('0')


n = int(input())
s = input()
no0 = s.count('0')
no1 = s.count('1')
print(abs(no0 - no1))


n = int(input())
s = input()
one = 0
zero = 0
for f in range(n):
	if s[f] == '0':
		zero += 1
	else:
		one += 1
if zero > one:
	print(zero - one)
else:
	print(n - zero * 2)


sa = int(input())
d = input()
k = d.count('1')
s = d.count('0')
print(abs(k - s))


n = int(input())
a = list(input())
b = a.count('0')
c = a.count('1')
print(len(a) - min(b, c) * 2)


def Repeticiones(Elem, Cadena):
	Cont = 0
	for Elemento in Cadena:
		if Elemento == Elem:
			Cont = Cont + 1
	return Cont
N = int(input(''))
Cad = input('')
Ceros = Repeticiones('0', Cad)
Unos = Repeticiones('1', Cad)
if Ceros == Unos and Ceros > 2:
	print(0)
else:
	Long = len(Cad)
	if Long > 2:
		if Ceros > Unos:
			X = Unos * 2
			Long = Long - X
		else:
			X = Ceros * 2
			Long = Long - X
		print(Long)
	elif Ceros == Unos:
		print(0)
	elif Long == 1:
		print(1)
	else:
		print(2)


x = input()
y = input()
(one, zero) = (0, 0)
for i in range(int(x)):
	if y[i] == '1':
		one += 1
	else:
		zero += 1
print(abs(one - zero))


def zeros_ones():
	input()
	s = input()
	stack = []
	for c in s:
		if len(stack) == 0 or stack[-1] == c:
			stack.append(c)
		else:
			stack.pop()
	print(len(stack))
zeros_ones()


n = int(input())
a = input()
array = [a.count('1'), a.count('0')]
print(max(array) - min(array))


n = int(input())
s = input()
k_zero = s.count('0')
k_one = n - k_zero
print(n - 2 * min(k_one, k_zero))


from sys import stdin

def main():
	n = int(stdin.readline())
	string = stdin.readline().strip()
	onesCnt = zerosCnt = 0
	for i in string:
		if i == '1':
			onesCnt += 1
		else:
			zerosCnt += 1
	print(abs(zerosCnt - onesCnt))
main()


n = int(input())
m = input()
x = m.count('1')
y = m.count('0')
print(abs(x - y))


print(abs(int(input()) - 2 * sum(list((int(x) for x in input())))))


import sys
n = int(sys.stdin.readline())
array = sys.stdin.readline()
zeros = 0
ones = 0
for i in array:
	if i == '0':
		zeros += 1
	elif i == '1':
		ones += 1
print(n - min(zeros, ones) * 2)


n = int(input())
a = map(int, list(input()))
print(abs(n - 2 * sum(a)))


n = int(input())
a = input().strip()
st = [-1 for i in range(n)]
pos = -1
ans = len(a)
for i in a:
	if pos == -1:
		pos += 1
		st[pos] = i
	elif st[pos] == i:
		pos += 1
		st[pos] = i
	else:
		pos -= 1
		ans -= 2
print(ans)


n = int(input())
s = input()
st = ['$']
for it in s:
	if it != st[-1] and st[-1] != '$':
		st.pop()
	else:
		st.insert(len(st), it)
print(len(st) - 1)


n = int(input())
s = input()
c = 0
f = 0
for i in range(len(s)):
	if int(s[i]) == 0:
		c += 1
	else:
		f += 1
print(abs(c - f))


(x, li) = (int(input()), list(input()))
print(abs(li.count('0') - li.count('1')))


n = int(input())
s = input()
stack = []
for i in range(n):
	if len(stack) == 0:
		stack.append(s[i])
	else:
		temp = stack[len(stack) - 1]
		if temp + s[i] == '01' or temp + s[i] == '10':
			stack.pop()
		else:
			stack.append(s[i])
print(len(stack))


n = int(input())
s = input()
a = [0, 0]
for i in range(n):
	a[int(s[i])] += 1
print(n - 2 * min(a))


l = int(input())
s = input()
a = s.count('0')
b = s.count('1')
print(l - 2 * min(a, b))


n = input()
a = str(input())
k = p = int(0)
if a.find('1') != -1:
	k = a.count('1')
else:
	k = 0
if a.find('0') != -1:
	p = a.count('0')
else:
	p = 0
print(max(k, p) - min(k, p))


n = int(input())
s = list(input())
f = s.count('1')
x = s.count('0')
print(abs(f - x))


n = int(input())
n_string = input()
count_1 = n_string.count('1')
print(abs(n - 2 * count_1))


n = input()
m = input()
c = 0
d = 0
for i in m:
	if i == '0':
		c = c + 1
	else:
		d = d + 1
print(abs(c - d))


def solve(n, l):
	a = l.count('0')
	return n - 2 * min(a, n - a)
n = int(input())
l = input()
print(solve(n, l))


input()
e = input()
print(abs(e.count('0') - e.count('1')))


length = int(input())
string = input()
zeros = 0
ones = 0
for digit in string:
	if digit == '0':
		zeros += 1
	else:
		ones += 1
if zeros > ones:
	zeros -= ones
	print(zeros)
else:
	ones -= zeros
	print(ones)


input()
n = input()
print(abs(len(n) - 2 * n.count('1')))


n = int(input())
s = input()
(k, h) = (0, 0)
for i in range(n):
	if s[i] == '0':
		k += 1
	else:
		h += 1
if h > k:
	print(h - k)
else:
	print(k - h)


n = int(input())
s = input()
m = min(s.count('0'), s.count('1'))
print(n - 2 * m)


input()
s = input()
s_0 = s.count('0')
s_1 = s.count('1')
print(abs(s_0 - s_1))


n = int(input())
s = str(input())
n1 = 0
n2 = 0
for i in range(n):
	if s[i] == '1':
		n1 = int(n1) + 1
	else:
		n2 = int(n2) + 1
print(abs(n1 - n2))


n = input()
s = input()
c1 = 0
c0 = 0
for i in range(len(s)):
	if s[i] == '0':
		c0 += 1
	else:
		c1 += 1
cmin = min(c1, c0)
sol = len(s) - 2 * cmin
if sol < 0:
	print(0)
else:
	print(sol)


a = int(input())
b = input().count('1')
print(abs(a - 2 * b))


n = int(input())
st = input()
count_0 = st.count('0')
count_1 = n - count_0
if count_1 >= count_0:
	print(n - 2 * count_0)
else:
	print(n - 2 * count_1)


n = int(input())
s = input()
a = sum(('0' == i for i in s))
b = sum(('1' == i for i in s))
print(abs(a - b))


length = int(input())
digits = input()
zeros = 0
ones = 0
for i in range(0, length, 1):
	if digits[i] == '0':
		zeros += 1
	elif digits[i] == '1':
		ones += 1
if zeros > ones:
	zeros = ones
	count = length - (zeros + ones)
	print(count)
else:
	ones = zeros
	count = length - (zeros + ones)
	print(count)


import collections
import math

def sortBy(a):
	return a[0]

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def solve(lst):
	zeros = 0
	for i in lst:
		if i == '0':
			zeros += 1
	return abs(zeros - (len(lst) - zeros))
k = int(input())
print(solve(input()))


b = input()
a = input()
num_1 = 0
num_0 = 0
for x in a:
	if x == '1':
		num_1 += 1
	else:
		num_0 += 1
print(abs(num_1 - num_0))


import math
z = int(input())
t = input()
o = 0
i = 0
for x in range(z):
	if t[x] == '1':
		i = i + 1
	else:
		o = o + 1
print(z - min(i, o) * 2)


n = int(input())
str = input()
k_0 = 0
k_1 = 0
for i in str:
	if int(i) == 0:
		k_0 += 1
	else:
		k_1 += 1
print(len(str) - min(k_0, k_1) * 2)


n = input()
s = input()
Zero = s.count('0')
One = s.count('1')
print(abs(Zero - One))


n = int(input())
x = list(map(int, list(input())))
countZero = len(list(filter(lambda a: a == 0, x)))
countOne = n - countZero
print(abs(countZero - countOne))


n = int(input())
word = input()
zero = word.count('0')
one = n - zero
print(n - min(zero, one) * 2)


N = int(input())
S = [int(x) for x in input()]
print(N - 2 * min(S.count(0), S.count(1)))


t = int(input())
p = str(input())
zeros = 0
uns = 0
for i in p:
	if i == '0':
		zeros += 1
	else:
		uns += 1
saida = t - 2 * min(zeros, uns)
print(saida)


n = int(input())
numbers = input()
ones = 0
for e in numbers:
	if e == '1':
		ones += 1
zeros = n - ones
result = abs(ones - zeros)
print(result)


n = int(input())
s = input()
c1 = 0
for i in range(len(s)):
	if s[i] == '0':
		c1 += 1
print(max(c1, n - c1) - min(c1, n - c1))


import sys
n = int(input())
s = input()
L = R = 0
for i in range(len(s)):
	if s[i] == '0':
		L = L + 1
	if s[i] == '1':
		R = R + 1
print(abs(L - R))


a = int(input())
b = input()
c = 0
for i in b:
	c = c + int(i)
d = a - c
print(int(((d - c) ** 2) ** 0.5))


n = int(input())
stack = list()
for x in input():
	stack.append(x)
	if len(stack) > 1:
		if stack[-2:] in (['0', '1'], ['1', '0']):
			stack.pop()
			stack.pop()
print(len(stack))


n = int(input())
inp = input()
ls = list(inp)
sum1 = 0
sum0 = 0
for i in range(n):
	if ls[i] == '1':
		sum1 += 1
	else:
		sum0 += 1
x = abs(sum1 - sum0)
print(x)


n = int(input())
s = input()
one = s.count('1')
zero = s.count('0')
if zero > one:
	print(zero - one)
elif one > zero:
	print(one - zero)
else:
	print(0)


n = int(input())
l = input()
o = l.count('1')
z = l.count('0')
if o == z:
	print(0)
else:
	print(abs(o - z))


def A556_1(n, string):
	number_of_ones = 0
	number_of_zeros = 0
	for i in string:
		if i == '1':
			number_of_ones = number_of_ones + 1
		if i == '0':
			number_of_zeros = number_of_zeros + 1
	sum = 0
	if number_of_ones > number_of_zeros:
		sum = number_of_ones - number_of_zeros
	else:
		sum = number_of_zeros - number_of_ones
	return sum
n = int(input())
string = input()
result = A556_1(n, string)
print(result)


a = int(input())
b = input()
if b.count('0') > b.count('1'):
	print(b.count('0') - b.count('1'))
else:
	print(b.count('1') - b.count('0'))


n = int(input())
s = input()
(zeros, ones) = (0, 0)
for i in s:
	if i == '0':
		zeros += 1
	else:
		ones += 1
print(max(zeros, ones) - min(zeros, ones))


x = int(input())
n = input()
a = n.count('1')
b = n.count('0')
print(abs(a - b))


n = int(input())
a = list(input())
a1 = [x for x in a if x == '1']
a0 = [x for x in a if x == '0']
print(abs(len(a1) - len(a0)))


n = int(input())
input_str = input()
num_zeros = 0
num_ones = 0
for num in input_str:
	if num == '0':
		num_zeros += 1
	else:
		num_ones += 1
result = abs(num_ones - num_zeros)
print(result)


n = int(input())
string = input()
oneCount = 0
zeroCount = 0
for i in range(0, n):
	if string[i] == '1':
		oneCount += 1
	else:
		zeroCount += 1
print(abs(oneCount - zeroCount))


l = int(input())
seq = input()
one = 0
zero = 0
for i in seq:
	if i == '1':
		one += 1
	elif i == '0':
		zero += 1
len_new_seq = one - zero
if len_new_seq < 0:
	len_new_seq *= -1
print(len_new_seq)


lenOfStrng = int(input())
strng = input()
(ones, zeros) = (0, 0)
for i in range(lenOfStrng):
	if strng[i] == '1':
		ones += 1
	else:
		zeros += 1
print(abs(ones - zeros))


x = input()
bi = input()
zeros = 0
ones = 0
for i in range(len(bi)):
	if bi[i] == '0':
		zeros += 1
	else:
		ones += 1
if ones >= zeros:
	print(ones - zeros)
else:
	print(zeros - ones)


a = input()
b = input()
print(len(b) - 2 * min(b.count('0'), b.count('1')))


n = int(input())
s = input()
length = len(s)
zero = s.count('0')
one = s.count('1')
while zero > 0 and one > 0:
	length -= 2
	zero -= 1
	one -= 1
print(length)


a = int(input())
s = str(input())
print(abs(s.count('0') - s.count('1')))


c = int(input())
x = input().count('1')
print(c - 2 * min(x, c - x))


x = int(input())
nums = input()
print(abs(x - 2 * nums.count('1')))


n = int(input())
s = str(input())
if 1 <= n <= 2 * 10 ** 5 and len(s) == n and s.isdigit():
	a = s.count('0')
	b = s.count('1')
	if a == n or b == n:
		print(n)
	elif a > b:
		print(a - b)
	elif a < b:
		print(b - a)
	elif a == b:
		print(0)


n = int(input())
ch = list(input())
print(abs(ch.count('1') - ch.count('0')))


l = int(input())
s = str(input())
t = len(s)
sum = 0
count = 0
for i in range(0, l, 1):
	if s[i] == '0':
		sum += 1
	else:
		count += 1
b = min(sum, count)
print(l - 2 * b)


n = input()
inp = input()
a = []
a.append(inp[0])
lenA = 1
for i in range(1, len(inp)):
	if lenA - 1 < 0:
		a.append(inp[i])
		lenA = lenA + 1
		continue
	if a[lenA - 1] != inp[i]:
		a.pop()
		lenA = lenA - 1
	else:
		a.append(inp[i])
		lenA = lenA + 1
print(len(a))


from sys import stdin
max_val = int(10000000000000.0)
min_val = int(-10000000000000.0)

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

def read_ints():
	return [int(x) for x in stdin.readline().split()]

def read_str():
	return input()

def read_strs():
	return [x for x in stdin.readline().split()]
lens = read_int()
strs = read_str()
ones = strs.count('1')
zero = strs.count('0')
print(max(ones, zero) - min(ones, zero))


n = int(input())
palavra = input()
uns = 0
zeros = 0
for e in palavra:
	if e == '1':
		uns += 1
	if e == '0':
		zeros += 1
resposta = abs(uns - zeros)
print(resposta)


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


n = int(input())
s = input()
k1 = s.count('1')
k0 = len(s) - k1
print(k1 + k0 - 2 * min(k1, k0))


from collections import Counter
n = int(input())
counter = Counter(input())
if len(counter) == 1:
	print(max(counter.values()))
else:
	print(max(counter.values()) - min(counter.values()))


n = int(input())
string = input()
ones = 0
zeros = 0
for i in range(len(string)):
	if int(string[i]) == 0:
		zeros += 1
	else:
		ones += 1
if zeros >= ones:
	result = zeros - ones
else:
	result = ones - zeros
print(result)


def solve(s, n):
	cnt0 = s.count('0')
	cnt1 = s.count('1')
	return cnt0 + cnt1 - 2 * min(cnt0, cnt1)
n = int(input())
s = input()
print(solve(s, n))


t = 1
while t > 0:
	t -= 1
	n = int(input())
	s = input()
	c1 = s.count('1')
	c0 = s.count('0')
	print(abs(c1 - c0))


n = int(input())
foo = input()
one = foo.count('1')
zero = foo.count('0')
print(n - 2 * min(one, zero))


x = int(input())
y = input()
z = 0
e1 = 0
e0 = 0
while z < x:
	if y[z] == '1':
		e1 += 1
	else:
		e0 += 1
	z += 1
if e0 == e1:
	print(0)
else:
	print(x - min(e0, e1) * 2)


a = int(input())
t = input()
print(abs(t.count('1') - t.count('0')))


a = input()
a = input()
print(abs(len(list([x for x in a if x == '1'])) - len(list([x for x in a if x == '0']))))


def oz():
	n = int(input())
	if n == 1:
		return 1
	nums = [int(i) for i in input()]
	nums.sort()
	res = 0
	i = 0
	j = n - 1
	while nums[i] == 0 and nums[j] == 1:
		n -= 2
		i += 1
		j -= 1
	return n
print(str(oz()))


n = int(input())
s = list(input())
one = list(filter(lambda x: x == '1', s))
zero = list(filter(lambda x: x == '0', s))
print(abs(len(one) - len(zero)))


n = int(input().strip())
s = input().strip()
arr = list(map(int, s))
ones = 0
zeros = 0
for i in arr:
	if i == 1:
		ones += 1
	else:
		zeros += 1
print(n - 2 * min(ones, zeros))


n = int(input())
s = input()
a = s.count('1')
b = s.count('0')
if a >= b:
	c = b
elif a < b:
	c = a
print(n - c * 2)


zero = 0
one = 0
n = int(input())
st = input()
for i in st:
	if i == '0':
		zero = zero + 1
	else:
		one = one + 1
print(abs(one - zero))


t = int(input())
a = input()
m = a.count('1')
n = a.count('0')
print(abs(m - n))


n = int(input())
s = input()
answer = 0
for i in s:
	if i == '1':
		answer += 1
	else:
		answer -= 1
print(abs(answer))


from sys import stdin
n = int(stdin.readline())
seqstr = stdin.readline()
ocounter = 0
zcounter = 0
for i in range(n):
	if int(seqstr[i]) == 0:
		ocounter += 1
	else:
		zcounter += 1
print(abs(ocounter - zcounter))


n = int(input())
s = input()
if s.count('1') == s.count('0'):
	print(0)
elif s.count('1') > s.count('0'):
	print(s.count('1') - s.count('0'))
else:
	print(s.count('0') - s.count('1'))


n = int(input())
s = input()
zero = s.count('0')
one = s.count('1')
print(abs(zero - one))


from collections import Counter
a = input()
b = input()

def counter(c):
	d = Counter(c)
	if d['0'] > d['1']:
		return d['0'] - d['1']
	else:
		return d['1'] - d['0']
print(counter(b))


n = int(input())
l = list(map(int, input()))
odd = list(filter(lambda x: x % 2 == 0, l))
even = len(l) - len(odd)
if len(odd) <= even:
	print(len(l) - len(odd) * 2)
else:
	print(len(l) - even * 2)


n = int(input())
x = input()
k1 = 0
k2 = 0
for i in range(n):
	if x[i] == '0':
		k1 += 1
	else:
		k2 += 1
print(abs(k1 - k2))


n = input()
mot = input()
rang = 0
L = ''
for i in mot:
	if i == '1':
		rang += 1
	else:
		rang -= 1
print(abs(rang))


x = int(input())
y = input()
j = 0
ones = 0
zeroes = 0
for j in range(len(y)):
	if y[j] == '0':
		zeroes += 1
	elif y[j] == '1':
		ones += 1
print(abs(zeroes - ones))


n = input()
l = input()
k1 = l.count('1')
k2 = l.count('0')
print(abs(k1 - k2))


a = int(input())
b = input()
c = list(b)
if b.count('1') >= b.count('0'):
	print(b.count('1') - b.count('0'))
else:
	print(b.count('0') - b.count('1'))


size = int(input())
arr = input()
ones = 0
zeros = 0
for i in arr:
	if i == '1':
		ones += 1
	else:
		zeros += 1
if ones > zeros:
	print(ones - zeros)
else:
	print(zeros - ones)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

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

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	n = I()
	c = collections.Counter(S())
	return n - min(c['1'], c['0']) * 2
print(main())


n = int(input())
string = input()
counter1 = 0
counter2 = 0
for i in string:
	if i == '1':
		counter1 += 1
	else:
		counter2 += 1
print(len(string) - 2 * min(counter1, counter2))


t = int(input())
arr = input()
x = arr.count('1')
y = arr.count('0')
print(abs(x - y))


n = int(input())
s = input()
stack = []
for c in s:
	if stack == []:
		stack.append(c)
	elif stack[len(stack) - 1] + c == '10' or stack[len(stack) - 1] + c == '01':
		stack.pop(len(stack) - 1)
	else:
		stack.append(c)
print(len(stack))


n = int(input())
a = input()
cnt0 = 0
cnt1 = 0
for i in range(n):
	if a[i] == '0':
		cnt0 += 1
	else:
		cnt1 += 1
print(abs(cnt1 - cnt0))


l = int(input())
s = input()
n_1 = s.count('1')
n_0 = l - n_1
print(l - 2 * min(n_1, n_0))


tamanho_string = int(input())
string = input()
count_1 = 0
count_2 = 0
for i in string:
	if i == '1':
		count_1 += 1
	else:
		count_2 += 1
resultado = abs(count_1 - count_2)
print(resultado)


n = int(input())
s = input()
s = s.replace('', ' ').strip()
l = list(map(int, s.split(' ')))
one = l.count(1)
null = l.count(0)
if one > null:
	r = one - null
	print(r)
elif null > one:
	r = null - one
	print(r)
else:
	print(0)


n = int(input())
array = list(input())
count_0 = 0
count_1 = 0
for a in array:
	if a == '0':
		count_0 += 1
	else:
		count_1 += 1
if count_0 > count_1:
	print(count_0 - count_1)
else:
	print(count_1 - count_0)


def android(s):
	val = abs(s.count('1') - s.count('0'))
	return val
n = int(input())
s = input()
print(android(s))


l = int(input())
st = input()
o = 0
z = 0
for i in st:
	if i == '0':
		z = z + 1
	else:
		o = o + 1
print(abs(z - o))


n = int(input())
s = input()
count1 = s.count('1')
count0 = s.count('0')
a = abs(count1 - count0)
print(a)


x = int(input())
z = list(input())
q = []
q.append(z[0])
for w in range(1, x):
	if len(q) == 0:
		q.append(z[w])
	elif q[-1] == z[w]:
		q.append(z[w])
	else:
		del q[-1]
print(len(q))


input()
k = input()
print(abs(k.count('1') - (len(k) - k.count('1'))))


n = int(input())
a = input()
one = a.count('1')
zero = a.count('0')
print(abs(one - zero))


def main():
	n = int(input())
	s = input()
	one = 0
	zero = 0
	for i in s:
		if i == '1':
			if zero > 0:
				zero -= 1
			else:
				one += 1
		elif one > 0:
			one -= 1
		else:
			zero += 1
	print(zero + one)
main()


n = int(input())
string = str(input())
counts = {'1': 0, '0': 0}
for i in string:
	counts[i] += 1
print(abs(counts['1'] - counts['0']))


n = int(input())
v = input()
c0 = 0
c1 = 0
for i in range(n):
	if v[i] == '0':
		c0 += 1
	else:
		c1 += 1
if c0 < c1:
	print(c1 - c0)
else:
	print(c0 - c1)


L = [input() for _ in ' ' * 2]
print(abs(L[1].count('0') - L[1].count('1')))


z = input
from math import ceil, log, gcd
n = int(z())
l = z()
one = l.count('1')
two = l.count('0')
print(abs(one - two))


N = int(input())
A = input()
print(abs(A.count('1') - A.count('0')))


(l, s) = (int(input().strip()), input().strip())
print(abs(s.count('1') * 2 - l))


string_lenght = int(input())
text = input()
ones = 0
zeros = 0
for n in range(string_lenght):
	number = int(text[n])
	if number == 0:
		zeros += 1
	elif number == 1:
		ones += 1
if ones > zeros:
	print(ones - zeros)
elif zeros > ones:
	print(zeros - ones)
else:
	print(0)


from sys import stdin, stdout, stderr, setrecursionlimit
from io import StringIO
setrecursionlimit(100000)

def read():
	return stdin.readline().rstrip()

def reada(sep=None, maxsplit=-1):
	return read().split(sep, maxsplit)

def readint():
	return int(read())

def readia(sep=None, maxsplit=-1):
	return [int(a) for a in reada(sep, maxsplit)]
from collections import Counter
n = readint()
s = read()
c = Counter(s)
print(n - min(c['0'], c['1']) * 2)


n = int(input())
l = list(input())
x = l.count('1')
y = l.count('0')
print(abs(x - y))


n = int(input())
s = input()
s = list(s)
s.sort()
if '1' in s:
	i = s.index('1')
	(t0, t1) = (n - i, i)
	print(n - 2 * min(t0, t1))
else:
	print(n)


n = int(input())
a = input()
kol1 = 0
kol0 = 0
for i in range(len(a)):
	if a[i] == '1':
		kol1 += 1
	else:
		kol0 += 1
print(abs(kol1 - kol0))


n = int(input())
b = input()
z = 0
o = 0
for i in b:
	if i == '0':
		o += 1
	else:
		z += 1
if o == z:
	print('0')
elif o > z:
	print(o - z)
else:
	print(z - o)


n = int(input())
s = input()
c = 0
x = 0
for i in s:
	if i == '0':
		c = c + 1
	elif i == '1':
		x = x + 1
if x > c:
	print(n - 2 * c)
else:
	print(n - 2 * x)


import sys
from collections import defaultdict

def stdinWrapper():
	data = '8\n11101111\n\n\n'
	for line in data.split('\n'):
		yield line
if '--debug' not in sys.argv:

	def stdinWrapper():
		while True:
			yield input()
inputs = stdinWrapper()

def inputWrapper():
	return next(inputs)

def getType(_type):
	return _type(inputWrapper())

def getArray(_type):
	return [_type(x) for x in inputWrapper().split()]
cnt = getType(int)
data = getType(str)
oneCount = sum([int(x) for x in data])
zeroCount = len(data) - oneCount
print(abs(oneCount - zeroCount))


N = int(input())
Cad = input()
Unos = Cad.count('1')
Ceros = Cad.count('0')
if Unos > Ceros:
	mayor = Unos
	print(mayor - Ceros)
else:
	mayor = Ceros
	print(mayor - Unos)


lenx = int(input())
x = input()
y = x.count('0')
z = x.count('1')
print(abs(y - z))


n = int(input())
s = input()
stack = []
op = {'1': '0', '0': '1'}
for i in range(len(s)):
	curr = s[i]
	if len(stack) > 0:
		if stack[-1] == op[curr]:
			stack.pop(-1)
			continue
		else:
			stack.append(curr)
	else:
		stack.append(curr)
print(len(stack))


def apply_operation(n, strg):
	if n == 1:
		return 1
	arr = []
	for i in strg:
		if len(arr) == 0:
			arr.append(i)
		elif i != arr[-1]:
			arr.pop()
		else:
			arr.append(i)
	return len(arr)
n = int(input())
strg = input()
print(apply_operation(n, strg))


n = int(input())
st = input().count('1')
print(n - 2 * min(st, n - st))


a = int(input())
b = input()
a1 = b.count('1')
a2 = b.count('0')
print(max(a1, a2) - min(a1, a2))


n = input()
li = input()
n = int(n)
num = 0
for i in range(n):
	if li[i] == '0':
		num += 1
	elif li[i] == '1':
		num -= 1
print(abs(num))


n = int(input())
x = [i for i in input()]
c0 = 0
c1 = 0
for i in x:
	if i == '1':
		c1 += 1
	else:
		c0 += 1
print(c1 + c0 - 2 * min(c1, c0))


n = int(input())
a = input()
(x, z) = (a.count('0'), a.count('1'))
print(x + z - min(x, z) * 2)


n = int(input())
s = input()
num1 = 0
num0 = 0
for i in range(n):
	if s[i] == '1':
		num1 += 1
	else:
		num0 += 1
print(num1 + num0 - 2 * min(num1, num0))


a = int(input())
b = input()
print(a - min(b.count('1'), b.count('0')) * 2)


r = ''

def sol(s):
	i = 1
	stack = [s[0]]
	for i in range(1, len(s)):
		if stack == []:
			stack.append(s[i])
		elif s[i] != stack[-1]:
			stack.pop()
		else:
			stack.append(s[i])
	print(len(stack))
input()
s = input()
sol(s)


L = input()
s = input()
ans = 0
c1 = 0
c2 = 0
for i in range(len(s)):
	if s[i] == '0':
		if c2 > 0:
			ans += 2
			c2 -= 1
		else:
			c1 += 1
	if s[i] == '1':
		if c1 > 0:
			ans += 2
			c1 -= 1
		else:
			c2 += 1
print(len(s) - ans)


n = int(input())
x = input()
(x0, x1) = (0, 0)
for i in range(n):
	if x[i] == '1':
		x1 += 1
	else:
		x0 += 1
print(abs(x1 - x0))


n = int(input())
nums = str(input())
uns = nums.replace('0', '')
zeros = nums.replace('1', '')
print(abs(len(uns) - len(zeros)))


n = int(input())
string = input()
n1 = string.count('1')
n0 = string.count('0')
if n1 == n0:
	print(0)
elif n1 > n0:
	print(n - n0 * 2)
else:
	print(n - n1 * 2)


n = int(input())
text = input()
zero = 0
one = 0
for i in range(0, len(text)):
	if text[i] == '0':
		zero += 1
	else:
		one += 1
print(abs(zero - one))


import math
n = int(input())
a = list(input())
cnt = 0
for i in a:
	if i == '1':
		cnt += 1
	else:
		cnt -= 1
print(abs(cnt))


n = int(input())
s = input()
a = []
for i in range(0, n):
	if len(a) == 0:
		a.append(s[i])
		continue
	top = a[len(a) - 1]
	if s[i] == '0' and top == '1':
		a.pop()
	elif s[i] == '1' and top == '0':
		a.pop()
	else:
		a.append(s[i])
print(len(a))


n = int(input())
s = input()
a = '0'
b = '1'
k = s.count(a)
m = s.count(b)
if k > m:
	t = n - 2 * m
	print(t)
else:
	t = n - 2 * k
	print(t)


(i, x) = (input(), input())
print(abs(x.count('1') - x.count('0')))


input()
a = [0, 0]
for c in input():
	a[int(c)] += 1
print(abs(a[0] - a[1]))


n = int(input())
l = [int(x) for x in input()]
if l[0] == 0:
	l = [1 - x for x in l]
s = 1
c = l[0]
for i in range(1, len(l)):
	c ^= l[i]
	if c == 1:
		s -= 1
	else:
		s += 1
		c = l[i]
if s < 0:
	s *= -1
print(s)


input()
s = input()
null = s.count('0')
one = s.count('1')
print(abs(null - one))


l = int(input())
st = input()
(zero, one) = (st.count('0'), st.count('1'))
print(zero + one - 2 * min(zero, one))


n = int(input())
w = str(input().strip())
ones = w.count('1')
zeros = w.count('0')
print(ones + zeros - 2 * min(ones, zeros))


lengths = int(input())
num = input()
num2 = list(num)
onelen = num2.count('1')
zerolen = num2.count('0')
print(lengths - 2 * min(onelen, zerolen))


from math import *
sInt = lambda : int(input())
mInt = lambda : map(int, input().split())
lInt = lambda : list(map(int, input().split()))
n = sInt()
a = input()
a = list(a)
(z, o) = (0, 0)
for i in a:
	if i == '0':
		z += 1
	else:
		o += 1
print(abs(z - o))


n = int(input())
f = str(input())
p = 0
for i in f:
	if i == '1':
		p += 1
	else:
		p -= 1
print(abs(p))


n = int(input())
s = list(input())
a = 0
b = 0
for i in s:
	if i is '1':
		a += 1
	elif i is '0':
		b += 1
p = 0
if a < b and a != 0 and (b != 0):
	p = 2 * a
elif a >= b and a != 0 and (b != 0):
	p = 2 * b
ans = 0
ans = n - p
print(ans)


import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
N = int(input())
A = list(input())
S = []
for (i, v) in enumerate(A):
	if S and S[-1] != v:
		S.pop()
	else:
		S.append(v)
print(len(S))


q = int(input())
arr = list(map(int, input()))
cnt = 0
for i in arr:
	if i == 0:
		cnt += 1
	else:
		cnt -= 1
print(abs(cnt))


n = int(input())
s = str(input())
lst = []
for i in s:
	if len(lst) != 0 and i == lst[-1] or len(lst) == 0:
		lst.append(i)
	elif i != lst[-1]:
		lst.pop()
print(len(lst))


input()
s = list(map(int, input()))
stack = []
for symb in s:
	if stack and stack[-1] == (not symb):
		stack.pop()
	else:
		stack.append(symb)
print(len(stack))


print(abs(int(input()) - 2 * input().count('0')))


n = int(input())
s = input()
s = list(str(s))
ze = s.count('0')
on = s.count('1')
print(len(s) - 2 * min(ze, on))


(n, a) = (int(input()), input())
c1 = a.count('1')
print(n - 2 * min(c1, n - c1))


n = int(input())
number = input()
zeros = number.count('1')
ones = number.count('0')
print(n - min(zeros, ones) * 2)


n = int(input())
s = input()
n_o = 0
n_z = 0
for i in s:
	if i == '0':
		n_o += 1
	else:
		n_z += 1
n_o = n_o - n_z
if n_o < 0:
	n_o = -n_o
print(n_o)


n = int(input())
st = input()
x = st.count('0')
y = st.count('1')
print(max(x, y) - min(x, y))


n = int(input())
k = input()
print(abs(k.count('0') - k.count('1')))


n = int(input().strip())
p = input().strip()
l = 0
d = 0
for i in p:
	if i == '0':
		l += 1
	else:
		d += 1
print(n - 2 * min(l, d))


line1 = int(input())
line2 = input()
print(abs(line2.count('1') - line2.count('0')))


n = int(input())
s1 = input()
z = 0
o = 0
for i in s1:
	if i == '0':
		z = z + 1
	else:
		o = o + 1
print(abs(o - z))


n = eval(input())
val = input()
l = val.count('1')
m = val.count('0')
r = len(val) - min(l, m) * 2
print(r)


n = int(input())
s = input()
c = 0
d = 0
for i in range(0, n):
	if s[i] == '1':
		c = c + 1
	else:
		d = d + 1
if c > d:
	print(c - d)
else:
	print(d - c)


n = int(input())
s = input().strip()
n1 = s.count('1')
n0 = n - n1
left = n - min(n0, n1) * 2
print(left)


n = int(input())
s = list(input())
zeros = s.count('0')
ones = n - zeros
minimum = min(zeros, ones)
print(n - 2 * minimum)


n = int(input())
s = input()
z = list(s)
print(abs(z.count('0') - z.count('1')))


n = int(input().strip())
s = input().strip()
st = []
for i in range(len(s)):
	if s[i] == '0':
		if len(st) > 0 and st[-1] == '1':
			st.pop()
		else:
			st.append('0')
	elif len(st) > 0 and st[-1] == '0':
		st.pop()
	else:
		st.append('1')
print(len(st))


def solve():
	n = int(input())
	s = input()
	a = s.count('1')
	b = n - a
	print(abs(a - b))
solve()


x = int(input())
s = input()
print(abs(s.count('1') - s.count('0')))


N = int(input())
S = input()
stack = []

def pop():
	try:
		return stack.pop()
	except:
		return None
for s in S:
	if len(stack) == 0:
		stack += [s]
		continue
	if s != stack[-1]:
		stack.pop()
	else:
		stack += [s]
print(len(stack))


n = int(input())
s = input()
a1 = []
b0 = []
for i in s:
	if i == '1':
		a1.append(i)
	else:
		b0.append(i)
print(abs(len(a1) - len(b0)))


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


n = int(input())
k = input()
o = k.count('0')
e = k.count('1')
print(abs(o - e))


n = int(input())
t = n
count1 = 0
count0 = 0
s = input()
a = list(s)
for i in range(n):
	if a[i] == '1':
		count1 += 1
	else:
		count0 += 1
print(abs(count1 - count0))


n = int(input())
r = input()
cnt1 = 0
cnt0 = 0
for i in range(n):
	if r[i] == '1':
		cnt1 += 1
	if r[i] == '0':
		cnt0 += 1
print(abs(cnt1 - cnt0))


l = int(input())
s = list(input())
ones = s.count('1')
zeros = s.count('0')
print(ones + zeros - 2 * min(ones, zeros))


def ans(n, a):
	z = o = 0
	for i in range(n):
		if a[i] == '0':
			z += 1
		else:
			o += 1
	return abs(z - o)
n = int(input())
a = input()
print(ans(n, a))


n = int(input())
s = str(input())
i = 0
k = 0
while i < n:
	if s[i] == '0':
		k += 1
	i += 1
print(abs(n - 2 * k))


n = int(input())
s = input()
a = 0
b = 0
for i in range(n):
	if s[i] == '1':
		a += 1
	else:
		b += 1
print(max(a, b) - min(a, b))


t = int(input())
x = input()
a = x.count('1')
b = x.count('0')
d = min(a, b)
d = 2 * d
print(len(x) - d)


n = int(input())
l = list((int(x) for x in input()))
on = l.count(1)
zo = l.count(0)
mi = min(zo, on)
print(len(l) - 2 * mi)


n = int(input())
a = input()
s = 0
for i in range(n):
	if a[i] == '0':
		s += 1
print(abs(n - 2 * s))


n = int(input())
s = input()
nr0 = 0
nr1 = 0
for x in s:
	if x == '0':
		nr0 += 1
	else:
		nr1 += 1
print(abs(nr0 - nr1))


(n, m) = (int(input()), input())
print(abs(m.count('0') - m.count('1')))


a = input()
a = input()
print(abs(len(list(filter(lambda x: x == '1', a))) - len(list(filter(lambda x: x == '0', a)))))


n = int(input())
sl = input()
s = list(sl)
r = abs(s.count('0') - s.count('1'))
print(r)


t = input()
y = input()
s = y.count('1')
x = y.count('0')
if x < s:
	g = int(t) - x * 2
else:
	g = int(t) - s * 2
print(g)


length = int(input())
string = input()
count_one = 0
count_zero = 0
for index in range(length):
	if string[index] == '1':
		count_one = count_one + 1
	elif string[index] == '0':
		count_zero = count_zero + 1
print(length - 2 * min(count_zero, count_one))


n = int(input())
s = input()
small = min(s.count('0'), s.count('1'))
print(n - 2 * small)


x = int(input())
l = input()
print(l.count('1') + l.count('0') - 2 * min(l.count('1'), l.count('0')))


n = int(input())
s = input()
from collections import Counter
c = Counter(s)
print(abs(c['0'] - c['1']))


n = input()
s = input()
zeros = uns = 0
for bit in s:
	if bit == '0' and (not uns):
		zeros += 1
	elif bit == '1' and (not zeros):
		uns += 1
	elif bit == '0':
		uns -= 1
	elif bit == '1':
		zeros -= 1
print(zeros + uns)


N = int(input())
S = input()

class SmartPile:

	def __init__(self, n=10):
		self.data = [0] * n
		self.pos = n
		self.n = n

	def add(self, i):
		self.pos -= 1
		self.data[self.pos] = i
		if self.pos < 0:
			raise 'Pile pleine !'

	def pop(self):
		self.pos += 1
		if self.pos > self.n:
			raise 'Pile vide'
		return self.data[self.pos - 1]

	def size(self):
		return self.n - self.pos
P = SmartPile(N)
for i in range(N):
	if P.size() == 0:
		P.add(i)
	else:
		a = P.pop()
		if int(S[a]) == int(S[i]):
			P.add(a)
			P.add(i)
print(P.size())


def main():
	n = input()
	s = input()
	d = {'0': 0, '1': 0}
	for c in s:
		d[c] += 1
	print(len(s) - min(d['0'], d['1']) * 2)

def __starting_point():
	main()
__starting_point()


n = int(input())
ch = input()
count0 = 0
for i in range(n):
	if ch[i] == '0':
		count0 += 1
count1 = n - count0
if count1 >= count0:
	ans = count1 - count0
else:
	ans = count0 - count1
print(ans)


def numOf01(st):
	(quant1, quant0) = (0, 0)
	for i in st:
		if i == '1':
			quant1 += 1
		else:
			quant0 += 1
	return (quant1, quant0)
n = int(input())
st = input()
(z, u) = numOf01(st)
if z == u:
	print('0')
else:
	print(abs(z - u))


n = int(input())
str = input()
zero = 0
unu = 0
for i in range(0, n):
	if str[i] == '0':
		zero += 1
	else:
		unu += 1
print(abs(zero - unu))


n = int(input())
s = input()
zeroes = s.count('0')
ones = s.count('1')
print(max(zeroes, ones) - min(zeroes, ones))


n = int(input())
s = input()
o = s.count('1')
z = s.count('0')
m = min(o, z)
a = n - 2 * m
print(a)


n = int(input())
entrada = input()
temp1 = 0
temp2 = 0
for i in range(len(entrada)):
	if entrada[i] == '0':
		temp1 += 1
	else:
		temp2 += 1
partial = min(temp1, temp2)
result = n - 2 * partial
print(result)


import math
import datetime
from sys import stdin
x = int(input())
y = input()
lis = []
for item in y:
	if len(lis) == 0:
		lis.append(item)
	elif item == '1':
		if lis[-1] == '0':
			del lis[-1]
		else:
			lis.append(item)
	elif lis[-1] == '1':
		del lis[-1]
	else:
		lis.append(item)
print(len(lis))


n = int(input())
s = input()
n0 = sum([1 for c in s if c == '0'])
n1 = len(s) - n0
print(abs(n0 - n1))


n = int(input())
s = input()
x1 = s.count('1')
x2 = s.count('0')
if x1 >= x2:
	print(x1 - x2)
else:
	print(x2 - x1)


import itertools as itls
import operator as op
from collections import Counter

def inputarray(func=int):
	return map(func, input().split())

def diff(v, x=0):
	v = iter(v)
	while True:
		try:
			y = next(v)
			yield (y - x)
			x = y
		except StopIteration:
			return
N = int(input())
A = Counter(map(int, list(input())))
print(abs(A[0] - A[1]))


n = int(input())
string = str(input())
print(abs(string.count('0') - string.count('1')))


n = int(input())
name = input()
zero = sum([1 for x in name if x == '0'])
one = sum([1 for x in name if x == '1'])
print(n - min(zero, one) * 2)


n = int(input())
(x, y) = map(input().count, ('1', '0'))
print(n - min(x, y) * 2)


input()
s = input()
num1 = s.count('1')
num0 = s.count('0')
print(max(num1 - num0, num0 - num1))


n = int(input())
l = input()
a = l.count('0')
b = l.count('1')

def menor(a, b):
	return a if a < b else b
c = menor(a, b)
print(n - 2 * c)


n = int(input())
s = list(input())
ones = s.count('1')
zeros = s.count('0')
if ones == zeros:
	print(0)
elif ones < zeros:
	print(n - 2 * ones)
else:
	print(n - 2 * zeros)


from collections import Counter
_ = input()
countr = Counter(input())
print(abs(countr['1'] - countr['0']))


s = int(input())
n = str(input())
nol = n.count('0')
satu = n.count('1')
while True:
	if nol == 0 or satu == 0:
		break
	nol -= 1
	satu -= 1
	if nol == 0 or satu == 0:
		break
if nol == 0:
	print(satu)
elif satu == 0:
	print(nol)
else:
	print('0')


size = int(input())
string = input()
(one, zeros) = (string.count('1'), string.count('0'))
print(size - 2 * one if one < zeros else size - 2 * zeros)


n = int(input())
a = input()
c = a.count('0')
d = a.count('1')
if c > d:
	print(c - d)
else:
	print(d - c)


n = int(input())
a = input()
count = 0
for i in range(n):
	if a[i] == '0':
		count = count + 1
	else:
		count = count - 1
if count < 0:
	print(0 - count)
else:
	print(count)


from sys import stdin
live = True
if not live:
	stdin = open('data.in', 'r')
n = int(stdin.readline().strip())
s = stdin.readline().strip()
stack = []
top = -1
for it in s:
	top += 1
	stack += [it]
	if top > 0 and stack[top - 1] != stack[top]:
		top -= 2
		del stack[-1]
		del stack[-1]
print(len(stack))
if not live:
	stdin.close()


n = int(input())
s = input()
t = min(s.count('1'), s.count('0'))
print(n - t * 2)


t = int(input())
s = input()
no0 = s.count('0')
no1 = s.count('1')
if no0 == no1:
	print(0)
elif no0 > no1:
	print(no0 - no1)
else:
	print(no1 - no0)


input()
w = input()
ans = abs(w.count('1') - w.count('0'))
print(ans)


input()
s = input()
ans = 0
for i in s:
	if i == '1':
		ans += 1
	else:
		ans -= 1
print(abs(ans))


n = int(input())
s = [int(ss) for ss in input()]
print(abs(s.count(1) - s.count(0)))


def main():
	length = int(input())
	string = input()
	countZero = 0
	countOne = 0
	for i in range(length):
		if string[i] == '0':
			countZero += 1
		else:
			countOne += 1
	min = countZero
	if countOne < countZero:
		min = countOne
	print(length - 2 * min)
main()


n = int(input())
s = input()
countzero = 0
countone = 0
for i in range(n):
	if s[i] == '0':
		countzero += 1
	else:
		countone += 1
print(n - 2 * min(countzero, countone))


n = int(input())
s = str(input())
if n == 1:
	print(n)
	exit()
cnt = 1
plus = 1
for i in range(1, len(s)):
	if s[i] != s[i - 1]:
		plus *= -1
	cnt += plus
print(abs(cnt))


import sys

def read_in():
	return [x.strip() for x in sys.stdin.readlines()]
lines = read_in()
ones = sum((1 for x in lines[1] if x == '1'))
print(abs(len(lines[1]) - 2 * ones))


n = int(input())
a = input()
zeros = a.count('0')
ones = a.count('1')
print(abs(ones - zeros))


input()
s = input()
a = s.count('1')
b = s.count('0')
print(abs(a - b))


input()
numbers = list(map(int, list(input())))
if 1 in numbers:
	one = len(numbers) - sorted(numbers).index(1)
else:
	one = 0
if 0 in numbers:
	two = len(numbers) - sorted(numbers, key=lambda x: -x).index(0)
else:
	two = 0
print(max(one, two) - min(one, two))


n = int(input())
s = input()
arr = []
arr.append(s[0])
for i in range(1, len(s)):
	if len(arr) > 0:
		if s[i] == '1':
			if arr[len(arr) - 1] == '0':
				arr.pop(len(arr) - 1)
			else:
				arr.append('1')
		elif arr[len(arr) - 1] == '1':
			arr.pop(len(arr) - 1)
		else:
			arr.append('0')
	else:
		arr.append(s[i])
print(len(arr))


input()
string = list(input())
stack = [string.pop()]
for i in range(0, len(string)):
	stack.append(string.pop())
	if len(set([stack[len(stack) - 1], stack[len(stack) - 2]])) == 2:
		stack.pop()
		stack.pop()
print(len(stack))


n = int(input())
s = input()
i = 0
check = 1
v = len(s) - 2 * min(s.count('1'), s.count('0'))
print(v)


n = int(input())
s = input()
c = s.count('1')
d = s.count('0')
print(abs(c - d))


import math
d = input()
n = input()
z = 0
o = 0
for i in range(len(n)):
	if n[i] == '0':
		z += 1
	else:
		o += 1
print(abs(z - o))


n = int(input())
s = input()
if '0' in s and '1' in s:
	print(n - 2 * min(s.count('0'), s.count('1')))
else:
	print(n)


n = int(input())
x = str(input())
a = 0
b = 0
for i in range(0, n, 1):
	if x[i] == '0':
		a = a + 1
	else:
		b = b + 1
print(max(a - b, b - a))


def solve():
	input()
	m = input()
	numb0 = m.count('0')
	numb1 = m.count('1')
	if numb1 >= numb0:
		return numb1 - numb0
	else:
		return numb0 - numb1
print(solve())


(_, l) = (input(), [])
for c in input():
	if l and c != l[-1]:
		del l[-1]
	else:
		l.append(c)
print(len(l))


nStr = input()
n = int(nStr)
string = input()
cnt0 = string.count('0')
cnt1 = string.count('1')
ans = max(cnt0, cnt1) - min(cnt0, cnt1)
print(ans)


input()
s = input()
print(abs(sum((x == '0' for x in s)) - sum((x == '1' for x in s))))


n = int(input())
s = input()
p = ''
q = ''
temp = 0
x = s.count('0')
y = s.count('1')
print(abs(x - y))


L = int(input())
s = input()
print(abs(s.count('0') * 2 - L))


a = int(input())
c = input()
f = 0
z = 0
for i in c:
	if i == '1':
		f = f + 1
	else:
		z = z + 1
if z > f:
	print(z - f)
elif f > z:
	print(f - z)
else:
	print('0')


n = int(input())
l = list(input())
(o, u) = (0, 0)
for i in range(len(l)):
	if l[i] == '0':
		o = o + 1
	else:
		u = u + 1
print(abs(u - o))


import sys
lines = []
for line in sys.stdin:
	lines.append(line)
length = int(lines[0])
code = lines[1]
count = 0
for digit in code:
	if digit == '1':
		count = count + 1
if 2 * count <= length:
	print(length - 2 * count)
else:
	print(2 * count - length)


(n, s) = (int(input()), input())
print(abs(sum((1 if x == '1' else 0 for x in s)) - sum((1 if x == '0' else 0 for x in s))))


def main():
	n = int(input())
	zc = 0
	s = input()
	for i in s:
		if i == '0':
			zc += 1
	print(abs(len(s) - zc - zc))
main()


n = int(input())
word = str(input())
ones = 0
zeroes = 0
for i in range(n):
	if word[i] == '1':
		ones += 1
	else:
		zeroes += 1
print(abs(zeroes - ones))


__author__ = 'myduomilia'
(n, s) = (input(), input())
(a, b) = (0, 0)
for val in s:
	if val == '0':
		a += 1
	else:
		b += 1
print(abs(a - b))


def zeros_ones():
	input()
	s = input()
	zeros = 0
	ones = 0
	for c in s:
		if c == '0':
			zeros += 1
		else:
			ones += 1
	print(abs(ones - zeros))
zeros_ones()


n = int(input())
s = list(input())
print(n - 2 * min(s.count('0'), s.count('1')))


input()
p = []
for i in input():
	p += [i]
	if len(p) >= 2 and p[-1] != p[-2]:
		p.pop()
		p.pop()
print(len(p))


_ = input()
target_str = input().strip()
print(abs(target_str.count('0') - target_str.count('1')))


_ = input()
s = input()
ans = 0
for i in range(len(s)):
	if s[i] == '1':
		ans += 1
	if s[i] == '0':
		ans -= 1
print(abs(ans))


__author__ = 'y'
n = int(input())
s = input()
n_zeros = s.count('0')
n_ones = s.count('1')
print(abs(n_zeros - n_ones))


import time

def countPairs(tstr):
	o = 0
	z = 0
	for x in tstr:
		if x == '0':
			z += 1
		else:
			o += 1
	return abs(o - z)

def removePairs(tstr):
	pattern = ['01', '10']
	nstr = tstr
	x = 0
	while x <= len(nstr):
		if nstr[x:x + 2] in pattern:
			nstr = nstr[:x] + nstr[x + 2:]
			x = 0
		else:
			x += 1
	return nstr
n = int(input())
tstr = input()
start_time = time.time()
print(countPairs(tstr))


s = int(input())
l = input()
print(abs(l.count('1') - l.count('0')))


n = int(input())
str = list(input())
print(f"{n - min(str.count('1'), str.count('0')) * 2}")


x = int(input())
y = input()
lst = []
a = 0
b = 0
for i in range(x):
	if y[i] == '1':
		a += 1
c = x - a - a
if c < 0:
	print(c * -1)
else:
	print(c)


n = int(input())
a = input()
if a.count('0') == a.count('1'):
	print('0')
else:
	print(abs(a.count('0') - a.count('1')))


isDebug = False
n = int(input())
s = input()
n0 = 0
n1 = 0
for c in s:
	if c == '0':
		n0 = n0 + 1
	else:
		n1 = n1 + 1
print(f'n0={n0}, n1={n1}') if isDebug else ''
print(f'{n - 2 * min(n0, n1)}')


n = int(input())
s = input()[:n]
if s.count('0') == s.count('1'):
	print(0)
else:
	print(abs(s.count('0') - s.count('1')))


n = int(input())
a = input()
zero_count = 0
one_count = 0
for i in a:
	if i == '0':
		zero_count += 1
	elif i == '1':
		one_count += 1
print(zero_count - one_count) if zero_count > one_count else print(one_count - zero_count)


input()
j = input()
print(abs(j.count('0') - j.count('1')))


n = int(input())
a = list(input())
flag0 = flag1 = 0
for i in range(n):
	if a[i] == '1':
		flag1 += 1
	else:
		flag0 += 1
if flag0 < flag1:
	n -= flag0 * 2
	print(n)
elif flag1 < flag0:
	n -= flag1 * 2
	print(n)
else:
	print('0')


size = int(input())
num = input()
ones_count = num.count('1')
zeros_count = num.count('0')
if ones_count > zeros_count:
	print(ones_count - zeros_count)
else:
	print(zeros_count - ones_count)


lenght = int(input())
strToevaluate = input()
ceros = 0
ones = 0
for i in range(lenght):
	if strToevaluate[i] == '1':
		ones += 1
	else:
		ceros += 1
print(abs(ceros - ones))


cnt_0 = 0
cnt_1 = 0
n = int(input())
asd = input()
for i in asd:
	if i == '0':
		cnt_0 += 1
	elif i == '1':
		cnt_1 += 1
cnt_0 = min(cnt_0, cnt_1)
print(n - 2 * cnt_0)


_ = input()
s = input()
z = s.count('0')
o = s.count('1')
print(abs(z - o))


N = int(input())
a = input()
odin = a.count('1')
dva = N - odin
print(N - 2 * min(odin, dva))


n = int(input())
i = input()
a = i.count('1')
b = i.count('0')
if a == b:
	print('0')
elif a > b:
	d = a - b
	print(d)
else:
	print(b - a)


n = int(input())
x = input()
(one, zero) = (0, 0)
sum = n
for i in range(0, n):
	if x[i] == '0':
		zero = zero + 1
		if one:
			sum = sum - 2
			zero = zero - 1
			one = one - 1
	if x[i] == '1':
		one = one + 1
		if zero:
			sum = sum - 2
			zero = zero - 1
			one = one - 1
print(sum)


n = int(input())
s = list(input())
ans = []
for i in s:
	if len(ans) > 0 and ans[-1] != i:
		ans.pop(-1)
	else:
		ans.append(i)
print(len(ans))


length_string = int(input())
string = input()
zero = string.count('0')
one = string.count('1')
total = max(zero, one) - min(zero, one)
print(total)


n = int(input())
s1 = str(input())
a = 0
b = 0
for index in range(n):
	if s1[index] == '0':
		a += 1
	else:
		b += 1
print(max(a, b) - min(a, b))


input()
s = list(input())
print(abs(s.count('1') - s.count('0')))


n = int(input())
str = input()
str = list(str)
countz = 0
counto = 0
for i in str:
	if i == '0':
		countz += 1
	else:
		counto += 1
if counto == countz:
	print(0)
else:
	if counto > countz:
		min = countz
	else:
		min = counto
	print(n - 2 * min)


n = int(input())
s = input()
(czero, cone) = (0, 0)
for i in range(0, len(s)):
	if s[i] == '1':
		cone += 1
	else:
		czero += 1
if czero == cone:
	print(0)
else:
	print(abs(czero - cone))


x = int(input())
y = input()
z = 0
o = 0
for i in y:
	if i == '1':
		o += 1
	if i == '0':
		z += 1
if int(z - o) >= 0:
	print(int(z - o))
else:
	print(int(z - o) * -1)


l = int(input())
s = str(input())
(count, count1) = (0, 0)
for i in range(l):
	if s[i] == '0':
		count += 1
	if s[i] == '1':
		count1 += 1
a = min(count, count1)
print(l - 2 * a)


n = int(input())
k = input()
ones = 0
zeros = 0
for i in k:
	if i == '1':
		ones += 1
	else:
		zeros += 1
res = abs(ones - zeros)
print(res)


from collections import Counter
x = int(input())
lis = list(map(int, input()))
inp = lis.count(0)
inp1 = lis.count(1)
if inp == inp1:
	ans = inp - inp1
	print(ans)
elif inp > inp1:
	ans = inp - inp1
	print(ans)
elif inp < inp1:
	ans = inp1 - inp
	print(ans)


length = int(input())
string = input()
count = 0
for digit in string:
	if digit == '1':
		count += 1
if count == 0:
	print(str(length))
	exit()
if length / count == 2:
	print('0')
elif length / count < 2:
	print(str((length - 2 * count) * -1))
else:
	print(str(length - 2 * count))


from math import sqrt, pow, ceil
from decimal import *
l1 = int(input())
l2 = list(input())
l = 0
o = 0
for i in range(l1):
	if l2[i] == '1':
		l += 1
	else:
		o += 1
print(l1 - 2 * min(l, o))


n = int(input())
string = input()
counter = 0
counter_0 = 0
for i in range(len(string)):
	if string[i] == '1':
		counter += 1
	else:
		counter_0 += 1
print(abs(counter - counter_0))


n = int(input())
s = str(input())
o = s.count('1')
z = s.count('0')
print(max(o, z) - min(o, z))


n = int(input())
a = input()[:n]
count_zero = a.count('0')
count_one = a.count('1')
if count_zero > count_one:
	print(n - count_one * 2)
elif count_one > count_zero:
	print(n - count_zero * 2)
elif count_zero == count_one:
	print(n - count_zero * 2)
elif count_zero == count_one and len(a) == count_one + count_zero:
	print(0)


n = int(input())
(z, o) = map(input().count, ('0', '1'))
print(abs(z - o))


from bisect import bisect_left, bisect_right
n = int(input())
line = sorted(input())
zero = bisect_right(line, '0') - bisect_left(line, '0')
print(n - min(zero, n - zero) * 2)


length = int(input())
string = input()
zero_count = 0
one_count = 0
for i in range(length):
	if string[i] == '1':
		one_count += 1
	else:
		zero_count += 1
if one_count >= zero_count:
	print(length - 2 * zero_count)
else:
	print(length - 2 * one_count)


n = int(input())
A = input()
d = {'1': 0, '0': 0}
for val in A:
	if val in d:
		d[val] += 1
x = list(d.values())
Min = min(x)
print(n - 2 * Min)


import sys
from random import choice, randint
inp = sys.stdin.readline
out = sys.stdout.write
flsh = sys.stdout.flush
sys.setrecursionlimit(10 ** 9)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def MI():
	return map(int, inp().strip().split())

def LI():
	return list(map(int, inp().strip().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines().strip()]

def LI_():
	return [int(x) - 1 for x in inp().strip().split()]

def LF():
	return [float(x) for x in inp().strip().split()]

def LS():
	return inp().strip().split()

def I():
	return int(inp().strip())

def F():
	return float(inp().strip())

def S():
	return inp().strip()

def pf(s):
	return out(s + '\n')

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def main():
	n = I()
	s = S()
	c0 = s.count('0')
	c1 = s.count('1')
	ans = abs(c0 - c1)
	pf(str(ans))
main()


n = int(input())
s = input()
z = 0
for i in s:
	if i == '0':
		z = z + 1
print(n - min(z, n - z) * 2)


n = int(input())
s = input()
sum_zero = s.count('0')
sum_one = s.count('1')
print(abs(sum_zero - sum_one))


n = int(input())
a = list(map(int, input()))
c = a.count(1)
d = a.count(0)
print(abs(c - d))


n = int(input())
s = input()
count_1 = 0
count_0 = 0
for i in range(n):
	if s[i] == '0':
		count_0 += 1
	else:
		count_1 += 1
print(abs(count_0 - count_1))


n = int(input())
a = input()
answer = 0
answer2 = 0
for i in a:
	if i == '1':
		answer += 1
	else:
		answer2 += 1
print(n - min(answer, answer2) * 2)


n = int(input())
s = input()
ones = 0
for i in s:
	if i == '1':
		ones += 1
print(abs(ones - (len(s) - ones)))


n = int(input())
s = input().split()
a = s[0]
print(abs(a.count('0') - a.count('1')))


n = int(input())
s = input()
a = s.count('1')
print(abs(n - a - a))


def countPair(string, n):
	counter1 = 0
	counter0 = 0
	for i in range(n):
		number = int(string[i])
		if number == 1:
			counter1 += 1
		else:
			counter0 += 1
	dif = counter1 - counter0
	if dif < 0:
		return dif * -1
	return dif
n = int(input())
string = input()
print(countPair(string, n))


def Main():
	n = int(input())
	strr = input()
	last = ''
	for c in strr:
		if len(last) == 0 or last.endswith(c):
			last += c
		else:
			last = last[:-1]
	print(len(last))
Main()


n = int(input())
s = input()
i = 0
s1 = 0
s2 = 0
while i < n:
	if s[i] == '0':
		s1 += 1
	else:
		s2 += 1
	i += 1
s1 -= s2
if s1 < 0:
	s1 *= -1
print(s1)


n = input()
n = input()
print(abs(n.count('0') - n.count('1')))


n = int(input())
s = input()
count_1 = s.count('1')
count_0 = s.count('0')
if count_1 > count_0:
	print(count_1 - count_0)
else:
	print(count_0 - count_1)


qtd = int(input())
string = input()
c0 = string.count('0')
c1 = string.count('1')
ans = len(string) - 2 * min(c0, c1)
print(ans)


import sys
import math
input = sys.stdin.readline

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

def str_array():
	return input().strip().split()

def lower_letters():
	lowercase = [chr(i) for i in range(97, 97 + 26)]
	return lowercase

def upper_letters():
	uppercase = [chr(i) for i in range(65, 65 + 26)]
	return uppercase
n = input()
no = input()
print(abs(no.count('0') - no.count('1')))


n = input()
s = input()
n_o = len(list((i for i in s if i == '1')))
n_z = len(list((i for i in s if i == '0')))
print(max(n_o, n_z) - min(n_o, n_z))


n = int(input())
s = input()
n0 = s.count('0')
n1 = s.count('1')
print(n - 2 * min(n0, n1))


s = int(input())
n = input()
c = 1
l1 = []
temp = True
for i in range(s - 1):
	if n[i] == n[i + 1]:
		c += 1
	else:
		if temp:
			l1.append(c)
			temp = False
		else:
			l1.append(-c)
			temp = True
		c = 1
if temp:
	l1.append(c)
else:
	l1.append(-c)
print(abs(sum(l1)))


a = int(input())
b = input()
zero = 0
one = 0
for i in range(a):
	if b[i] == '0':
		zero += 1
	else:
		one += 1
print(abs(one - zero))


from sys import stdin, stdout

def trace(f):

	def traced(*args, **kw):
		print('calling {} with args {}, {}'.format(f.__name__, args, kw))
		return f(*args, **kw)
	return traced

@trace
def f(x):
	print(x)

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

def readarr(sep=None, maxsplit=-1):
	return read().split(sep, maxsplit)

def readint():
	return int(read())

def readintarr(sep=None, maxsplit=-1):
	return [int(a) for a in readarr(sep, maxsplit)]

def write(*args, **kwargs):
	sep = kwargs.get('sep', ' ')
	end = kwargs.get('end', '\n')
	stdout.write(sep.join((str(a) for a in args)) + end)

def writearr(arr, sep=' ', end='\n'):
	stdout.write(sep.join((str(a) for a in arr)) + end)
n = readint()
s = list(read())
unos = s.count('1')
ceros = s.count('0')
write(abs(unos - ceros))


(n, z) = (int(input()), input())
print(abs(z.count('1') - z.count('0')))


n = int(input())
string = input()
ones = string.count('1')
zeros = n - ones
print(abs(ones - zeros))


from sys import stdin, stdout
n = int(stdin.readline())
s = stdin.readline()
one = s.count('1')
zero = n - one
stdout.write(str(abs(one - zero)) + '\n')


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
from collections import defaultdict
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

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

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

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

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
s = input()
print(abs(s.count('1') - s.count('0')))


n = int(input())
s_str = str(input())
s = [int(s_str[i] == '1') for i in range(0, len(s_str))]
One_count = sum(s)
Zero_count = len(s) - One_count
print(abs(One_count - Zero_count))


z = input('')
b = input('')
c = b
d = 0
e = 0
for i in c:
	if i == '1':
		e = e + 1
	elif i == '0':
		d = d + 1
print(abs(d - e))


from collections import Counter
n = int(input())
string = list(input())
counter = Counter(string)
print(abs(counter['1'] - counter['0']))


n = int(input())
s = input()
d = []
for i in s:
	d.append(i)
	if len(d) >= 2:
		if d[-1] == '0' and d[-2] == '1' or (d[-1] == '1' and d[-2] == '0'):
			d.pop()
			d.pop()
print(len(d))


n = int(input())
s = input().strip()
d = {}
one = 0
zero = 0
for i in s:
	if i == '1':
		one += 1
	else:
		zero += 1
print(abs(one - zero))


n = int(input())
s = input()
li = []
for i in range(n):
	if len(li) != 0:
		if s[i] != li[-1]:
			li.pop(-1)
		else:
			li.append(s[i])
	else:
		li.append(s[i])
print(len(li))


n = int(input())
s = input()
c = 0
c1 = 0
for i in range(n):
	if s[i] == '0':
		c = c + 1
	elif s[i] == '1':
		c1 = c1 + 1
f = min(c, c1)
print(n - 2 * f)


aa = int(input())
a = list(input())
ii = 0
o = 0
for i in a:
	if i == '0':
		o = o + 1
	elif i == '1':
		ii = ii + 1
print(abs(ii - o))


n = int(input())
s = input()
n1 = s.count('0')
n2 = s.count('1')
if n1 > n2:
	print(n1 - n2)
else:
	print(n2 - n1)


n = int(input())
s = input()
(res1, res2) = (0, 0)
for i in s:
	if i == '0':
		res1 += 1
	else:
		res2 += 1
print(n - min(res1, res2) * 2)


n = int(input())
s = list(input())
st = [s[0]]
for i in range(1, len(s)):
	if st and ord(st[0]) - ord('0') ^ ord(s[i]) - ord('0'):
		st.pop()
	else:
		st.append(s[i])
print(len(st))


n = int(input())
a = list(input())
(b, c) = ([], [])
while a != []:
	k = a.pop()
	if k == '1':
		if c == []:
			b.append(k)
		else:
			t = c.pop()
	if k == '0':
		if b == []:
			c.append(k)
		else:
			t = b.pop()
print(len(b) + len(c))


length = int(input())
number = input()
zeros = number.count('0')
ones = number.count('1')
print(abs(zeros - ones))


n = int(input())
s = input()
print(abs(n - 2 * s.count('0')))


n = int(input())
x = input()
x = list(x)
print(abs(x.count('1') - x.count('0')))


n = int(input())
string = input()
zero = 0
one = 0
for i in string:
	if i == '0':
		zero += 1
	else:
		one += 1
print(n - 2 * min(one, zero))


n = int(input())
d = input()
print(abs(d.count('1') - d.count('0')))


x = int(input())
str = input()
ones = 0
zeros = 0
for i in str:
	if i == '1':
		ones += 1
	else:
		zeros += 1
print(abs(zeros - ones))


n = input()
series = input()
num_zeros = series.count('0')
num_ones = series.count('1')
answer = abs(num_zeros - num_ones)
print(answer)


n = int(input())
s1 = input()
x1 = s1.count('0')
y1 = s1.count('1')
print(abs(x1 - y1))


n = int(input())
word = [int(x) for x in input()]
stack = []
for i in word:
	if len(stack) == 0:
		stack.append(i)
	elif i == 1 and stack[-1] == 0 or (i == 0 and stack[-1] == 1):
		stack.pop()
	else:
		stack.append(i)
print(len(stack))


n = int(input())
string = input()
line = [int(i) for i in string]
if len(line) == 1:
	print('1')
else:
	ones = line.count(1)
	zeros = line.count(0)
	print(abs(ones - zeros))


n = int(input())
l = [int(o) for o in input()]
count = 0
for k in l:
	if k == 1:
		count += 1
	else:
		count -= 1
print(abs(count))


a = int(input())
x = input()
z = (x.count('0'), x.count('1'))
print(max(z) - min(z))


n = int(input())
f = input()
f = list(f)
one = f.count('1')
two = f.count('0')
print(abs(one - two))


import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy
from itertools import chain, dropwhile, permutations, combinations
from collections import defaultdict, deque

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

def I():
	return int(input())

def LIST(n, m=None):
	return [0] * n if m is None else [[0] * m for i in range(n)]

def ELIST(n):
	return [[] for i in range(n)]

def MI(n=None, m=None):
	if n is None:
		(n, m) = VI()
	arr = LIST(n)
	for i in range(n):
		arr[i] = VI()
	return arr

def MS(n=None, m=None):
	if n is None:
		(n, m) = VI()
	arr = LIST(n)
	for i in range(n):
		arr[i] = input()
	return arr

def MIT(n=None, m=None):
	if n is None:
		(n, m) = VI()
	a = MI(n, m)
	arr = LIST(m, n)
	for (i, l) in enumerate(a):
		for (j, x) in enumerate(l):
			arr[j][i] = x
	return arr

def run(n, x, l, r):
	s = 0
	curr = 1
	for i in range(n):
		skip = (l[i] - curr) // x
		s += r[i] - curr - skip * x + 1
		curr = r[i] + 1
	print(s)

def main(info=0):
	n = I()
	s = list(input())
	print(n - min(s.count('0'), s.count('1')) * 2)

def __starting_point():
	main()
__starting_point()


n = input()
n = int(n)
string = input()
string = list(string)
string = [int(x) for x in string]
print(abs(string.count(1) - string.count(0)))


n = input()
nn = input()
m = str(nn)
x = []
for i in m:
	x.append(int(i))
print(abs(x.count(1) - x.count(0)))


from collections import Counter
n = int(input())
seq = input()
c = Counter(seq)
print(len(seq) - 2 * min(c['0'], c['1']))


import sys
n = sys.stdin.readline()
n = int(n)
t = sys.stdin.readline()
unos = 0
ceros = 0
for i in range(n):
	if t[i] == '1':
		unos += 1
	else:
		ceros += 1
print(max(ceros, unos) - min(ceros, unos))


n = int(input())
zn = str(input())
ones = 0
zeroes = 0
for zn_let in zn:
	if zn_let == '0':
		zeroes = zeroes + 1
	else:
		ones = ones + 1
answer = abs(ones - zeroes)
print(answer)


n = int(input())
c = list(map(int, input()))
u = [False for v in c]
(a, b) = (0, 1)
r = 0
while a >= 0 and a < n and (b >= 0) and (b < n):
	if c[a] + c[b] == 1:
		u[a] = True
		u[b] = True
		r += 2
	else:
		a += 1
		b += 1
	while a > 0 and a < n and u[a]:
		a -= 1
	while b < n and u[b]:
		b += 1
	if not u[a] and a == 0:
		while a < n and u[a]:
			a += 1
print(abs(n - r))


n = int(input())
st = input()
nz = 0
no = 0
for i in range(n):
	if st[i] == '0':
		nz += 1
	if st[i] == '1':
		no += 1
print(abs(no - nz))


x = int(input())
y = input()
z = list(y)
cv = min(z.count('0'), z.count('1'))
print(x - 2 * cv)


n = int(input())
s = input()
c = 0
d = 0
for i in range(len(s)):
	if s[i] == '1':
		c = c + 2
	if s[i] == '0':
		d = d + 2
print(len(s) - min(c, d))


n = int(input())
a = list(input())
b = [int(x) for x in a]
c = sum(b)
print(abs(n - 2 * c))


length = int(input())
number = input()
print(abs(number.count('0') - number.count('1')))


n = input()
k = input()
one = list(k)
one = [int(i) for i in one]
(a, c, i) = (0, 0, 0)
for i in one:
	if i == 0:
		c += 1
	else:
		a += 1
print(abs(a - c))


n = int(input())
num = input()
a = num.count('1')
b = num.count('0')
print(abs(a - b))


input()
string = input()
(o, z) = (0, 0)
for i in string:
	if i == '1':
		o += 1
	else:
		z += 1
print(abs(o - z))


n = int(input())
li = list(input())
one = 0
zero = 0
for i in li:
	if i == '1':
		one = one + 1
	else:
		zero = zero + 1
print(len(li) - 2 * min(zero, one))


n = int(input())
s = input()
l = []
l.append(s[0])
for i in range(1, n):
	if len(l) == 0:
		l.append(s[i])
	elif s[i] == '0' and l[len(l) - 1] == '0':
		l.append(s[i])
	elif s[i] == '0' and l[len(l) - 1] == '1':
		l.pop(len(l) - 1)
	elif s[i] == '1' and l[len(l) - 1] == '1':
		l.append(s[i])
	elif s[i] == '1' and l[len(l) - 1] == '0':
		l.pop(len(l) - 1)
print(len(l))


n = int(input())
s = input()
k1 = 0
k0 = 0
for i in range(n):
	if s[i] == '1':
		k1 += 1
	else:
		k0 += 1
print(n - min(k1, k0) * 2)


n = int(input())
string = input()
oneCount = 0
zeroCount = 0
for x in range(n):
	if string[x] == '0':
		zeroCount += 1
	else:
		oneCount += 1
if zeroCount > oneCount:
	print(zeroCount - oneCount)
elif zeroCount < oneCount:
	print(oneCount - zeroCount)
else:
	print('0')


n = int(input())
p = input()
c = p.count('0')
d = p.count('1')
print(abs(c - d))


n = int(input())
s = input()
a = s.count('0')
b = s.count('1')
if a == b:
	print('0')
else:
	t = abs(a - b)
	print(t)


n = int(input())
num = input()
s = 0
for i in num:
	if i == '0':
		s += 1
if n - 2 * s >= 0:
	print(n - 2 * s)
else:
	print(2 * s - n)


m = int(input())
n = input()
if n.count('1') - n.count('0') >= 0:
	print(n.count('1') - n.count('0'))
else:
	print(n.count('0') - n.count('1'))


l = int(input())
s = input()
d = {'1': 0, '0': 0}
for char in s:
	d[char] += 1
if d['1'] == d['0']:
	print(0)
else:
	print(l - 2 * min(d['1'], d['0']))


n = int(input())
number = [int(a) for a in input()]
numberone = sum(number)
numberzero = n - numberone
print(n - 2 * min(numberone, numberzero))


n = int(input())
s = list(str(input()))
print(max(s.count('1'), s.count('0')) - min(s.count('1'), s.count('0')))


n = int(input())
li = [int(x) for x in input()]
c1 = li.count(1)
c0 = li.count(0)
min = min(c1, c0)
l = len(li) - 2 * min
print(l)


t = int(input())
n = input()
a = n.count('1')
b = n.count('0')
print(abs(a - b))


import re

def __starting_point():
	x = int(input())
	s = input()
	(zeros, ones) = (0, 0)
	for char in s:
		if char == '0':
			zeros += 1
		if char == '1':
			ones += 1
	print(abs(zeros - ones))
__starting_point()


n = int(input())
a = str(input())
f = 0
for p in a:
	if p == '1':
		f += 1
s = n - f
if f > s:
	print(f - s)
else:
	print(s - f)


n = int(input())
number = input()
zero = 0
one = 0
for i in range(n):
	if number[i] == '1':
		one += 1
zero = n - one
print(n - 2 * min(zero, one))


n = int(input())
s = input()
cnt = s.count('0')
print(abs(len(s) - cnt * 2))


n = int(input())
a = input()
(one, z) = (0, 0)
for el in a:
	if el == '1':
		one += 1
	elif el == '0':
		z += 1
c = min(one, z)
print(n - 2 * c)


n = int(input())
inp2 = input()
ls = []
all_freq = {}
all_freq['0'] = 0
all_freq['1'] = 0
for i in inp2:
	if i in all_freq:
		all_freq[i] += 1
	else:
		all_freq[i] = 1
res = len(inp2) - min(all_freq['0'], all_freq['1']) * 2
print(res)


n = int(input())
string = input()
stack = ['a']
for e in string:
	if stack[-1] == '0' and e == '1' or (stack[-1] == '1' and e == '0'):
		stack.pop()
	else:
		stack.append(e)
print(len(stack) - 1)


n = int(input())
string = input()
number_of_zeroes = string.count('0')
number_of_ones = n - number_of_zeroes
print(abs(number_of_zeroes - number_of_ones))


n = int(input())
z = input()
z = list(z)
z.sort()
a = z.count('0')
b = z.count('1')
if a >= b:
	print(a - b)
else:
	print(b - a)


n = int(input())
st = input()
res1 = 0
res0 = 0
for c in st:
	if c == '1':
		res1 += 1
	elif c == '0':
		res0 += 1
print(n - min(res1, res0) * 2)


a = int(input())
b = input()
print(abs(b.count('0') - b.count('1')))


LengteString = input()
GetallenString = input()
Aantal1 = 0
Aantal0 = 0
for i in range(0, int(LengteString)):
	if GetallenString[i] == '0':
		Aantal0 += 1
	else:
		Aantal1 += 1
print(abs(Aantal0 - Aantal1))


n = int(input())
l = input()
z = 0
o = 0
for i in range(n):
	if l[i] == '0':
		z += 1
	else:
		o += 1
print(abs(z - o))


L = int(input())
S = input()
if S.count('0') > 0 and S.count('1') > 0:
	print(L - 2 * min(S.count('0'), S.count('1')))
else:
	print(L)


n = int(input())
string = list(str(input()))
zero = 0
one = 0
for i in string:
	if i == '1':
		one += 1
	elif i == '0':
		zero += 1
max_len = max(one, zero)
new_str = ''
i = 0
while i < int(max_len):
	if one == 0 or zero == 0:
		if one >= 1:
			ones = '1' * one
			new_str += ones
		elif zero >= 1:
			zeros = '0' * zero
			new_str += zeros
		break
	else:
		new_str += '10'
		one -= 1
		zero -= 1
	i += 1
print(len(new_str.replace('10', '')))


n = int(input())
s = input()
z = 0
o = 0
for x in range(0, s.__len__()):
	if s[x] == '1':
		o += 1
	else:
		z += 1
print(abs(o - z))


n = int(input())
st = input()
a = 0
for i in range(n):
	if st[i] == '1':
		a += 1
if len(st) - a - a >= 0:
	print(len(st) - a - a)
else:
	print(a + a - len(st))


import string
n = input()
s = str(input())
z_count = 0
o_count = 0
for i in s:
	if i == '1':
		o_count += 1
	if i == '0':
		z_count += 1
ans = abs(o_count - z_count)
print(ans)


input()
s = input()
n_ones = sum(map(lambda c: c == '1', s))
n_zeros = len(s) - n_ones
print(abs(n_ones - n_zeros))


n = int(input())
s = input().strip()
balance = 0
for ch in s:
	if ch == '0':
		balance -= 1
	else:
		balance += 1
print(abs(balance))


n = int(input())
str1 = input()
count_0 = str1.count('0')
count_1 = str1.count('1')
print(abs(count_0 - count_1))


size = int(input())
string = str(input())
zeros = 0
ones = 0
for i in string:
	if i == '0':
		zeros += 1
	else:
		ones += 1
print(size - 2 * min(zeros, ones))


n = input()
s = input()
(count0, count1) = (0, 0)
for c in s:
	if c == '0':
		count0 += 1
	else:
		count1 += 1
print(abs(count0 - count1))


l = int(input())
word = input()
ones = word.count('1')
zeros = word.count('0')
print(len(word) - 2 * min(ones, zeros))


a = int(input())
b = input().count('0')
print(abs(2 * b - a))


n = int(input())
str = input()
zeroes = str.count('0')
ones = str.count('1')
print(abs(zeroes - ones))


from sys import stdin, stdout

def main():
	n = int(stdin.readline())
	num = stdin.readline()
	stdout.write(str(max(num.count('0'), num.count('1')) - min(num.count('0'), num.count('1'))))
main()


StrLen = int(input())
String = input()
Zcount = 0
Ocount = 0
for i in range(StrLen):
	if String[i] == '0':
		Zcount += 1
	else:
		Ocount += 1
RemoveCount = min(Zcount, Ocount)
print(StrLen - RemoveCount * 2)


n = int(input())
st = input()
c1 = 0
c0 = 0
for i in range(n):
	if st[i] == '0':
		c0 += 1
	else:
		c1 += 1
print(n - 2 * min(c0, c1))


n = int(input())
i1 = input()
z_count = i1.count('0')
o_count = i1.count('1')
print(max(z_count, o_count) - min(z_count, o_count))


def sol():
	n = int(input())
	A = input()
	ones = 0
	for i in A:
		if i == '1':
			ones += 1
	z = n - ones
	print(abs(ones - z))
sol()


input()
line = input()
one = line.count('1')
zero = line.count('0')
print(abs(one - zero))


input()
s = input()
print(len(s) - 2 * min(s.count('1'), s.count('0')))


while True:
	try:
		n = map(int, input().split())
	except:
		break
	s = input()
	s = list(s)
	num1 = 0
	num2 = 0
	for i in s:
		if i == '1':
			num1 += 1
		else:
			num2 += 1
	if num1 < num2:
		(num1, num2) = (num2, num1)
	print(num1 - num2)


n = int(input())
s = input()
c = s.count('0')
k = n - c
print(abs(k - c))


n = int(input())
a = input()
ones = a.count('1')
zeros = a.count('0')
print(max(ones, zeros) - min(ones, zeros))


n = int(input())
s = input()
stack = []
for i in s:
	if len(stack) == 0:
		stack.append(i)
	elif stack[-1] != i:
		stack.pop()
	else:
		stack.append(i)
print(len(stack))


garbage = int(input())
x = input()
z = x.count('0')
o = x.count('1')
print(garbage - 2 * min(z, o))


import math, re

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

def solve():
	n = int(input())
	s = input()
	print(abs(s.count('1') - s.count('0')))
solve()


length = int(input())
number = input()
num0 = 0
num1 = 0
for character in number:
	if int(character) == 0:
		num0 += 1
	if int(character) == 1:
		num1 += 1
print(abs(num0 - num1))


len_string = int(input())
my_string = input()
if len_string != len(my_string):
	exit()
contOne = 0
contZero = 0
for i in my_string:
	if i == '1':
		contOne += 1
	else:
		contZero += 1
print(abs(contOne - contZero))


from sys import stdin, exit
n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()
stack = []
for cur in s:
	if len(stack) > 0:
		if stack[-1] != cur:
			stack.pop()
			n -= 2
		else:
			stack.append(cur)
	else:
		stack.append(cur)
print(n)


n = int(input())
s = input()
i = 0
cou = dict()
cou[1] = 0
cou[0] = 0
for i in range(n):
	if s[i] == '1':
		cou[1] += 1
	else:
		cou[0] += 1
dell = min(cou[0], cou[1]) * 2
print(n - dell)


n = int(input())
str = input()
a = str.count('0')
b = str.count('1')
if a - b > 0:
	print(a - b)
else:
	print(b - a)


n = int(input())
num = input()
one = num.count('1')
zero = num.count('0')
print(abs(one - zero))


import unittest
import sys
import re

class Zeroes:

	def __init__(self, args):
		self.list = args

	def reduce(self):
		result = 0
		ones = 0
		zeroes = 0
		for n in self.list:
			if n == 0:
				zeroes += 1
			else:
				ones += 1
		return abs(zeroes - ones)

	def calculate(self):
		result = self.reduce()
		return str(result)

def get_inputs(test_inputs=None):
	it = iter(test_inputs.split('\n')) if test_inputs else None

	def uinput():
		if it:
			return next(it)
		else:
			return input()
	num = int(uinput())
	ints = [int(n) for n in uinput()]
	return ints

def calculate(test_inputs=None):
	return Zeroes(get_inputs(test_inputs)).calculate()

class unitTests(unittest.TestCase):

	def test_sample_tests(self):
		self.assertEqual(calculate('4\n1100'), '0')
		self.assertEqual(calculate('5\n01010'), '1')
		self.assertEqual(calculate('8\n11101111'), '6')
		str = '1\n'
		for i in range(1001):
			str += '10011001'
		for i in range(10001):
			str += '10'
		self.assertEqual(calculate(str), '0')

	def test_get_inputs(self):
		self.assertEqual(get_inputs('4\n1100'), [1, 1, 0, 0])

	def test_Zeroes_class__basic_functions(self):
		d = Zeroes([1, 0, 0, 1])
		self.assertEqual(d.list[0], 1)
		self.assertEqual(d.reduce(), 0)
		d.list = [1, 1, 0, 0]
		self.assertEqual(d.reduce(), 0)
sys.setrecursionlimit(100000)
if sys.argv[-1] == '-ut':
	unittest.main(argv=[' '])
print(calculate())


i = int(input())
s = input()
z = 0
o = 0
for u in range(i):
	if s[u] == '0':
		z += 1
	elif s[u] == '1':
		o += 1
print(abs(z - o))


n = int(input())
word = input()
sol = min(word.count('0'), word.count('1'))
print(n - sol * 2)


n = int(input())
s = input()
n = len(s)
s_inxex = [1] * n
if n == 1:
	print('1')
	exit()
i = 0
j = 1

def next_idx(idx):
	global s_inxex, n
	idx += 1
	while idx < n and s_inxex[idx] == 0:
		idx += 1
	return idx
while j < n:
	if s[i] != s[j]:
		s_inxex[i] = 0
		s_inxex[j] = 0
		i = next_idx(i)
		j = next_idx(j)
	else:
		j = next_idx(j)
s_out = [x for (idx, x) in enumerate(s) if s_inxex[idx] == 1]
print(len(s_out))


ls = int(input())
word = input()
print(abs(word.count('1') - word.count('0')))


n = int(input())
str = list(input())
o = t = 0
for x in range(0, n):
	if str[x] == '1':
		o += 1
	if str[x] == '0':
		t += 1
print(max(o, t) - min(o, t))


n = int(input())
s = input()
print(abs(s.count('1') + s.count('0') - 2 * min(s.count('1'), s.count('0'))))


n = int(input())
z = input()
satu = 0
nol = 0
for i in z:
	if i == '1':
		satu += 1
	else:
		nol += 1
print(n - min(satu, nol) * 2)


from collections import deque
input()
s = input()
stack = deque([])
for c in s:
	if stack == deque([]):
		stack.append(c)
		continue
	if stack[stack.__len__() - 1] != c:
		stack.pop()
	else:
		stack.append(c)
print(stack.__len__())


i = input()
a = input()
print(len(a) - min(a.count('1'), a.count('0')) * 2)


n = int(input().strip())
s = input().strip()
digit_count = [s.count('0'), s.count('1')]
print(n - min(digit_count) * 2)


import sys
data = sys.stdin.readlines()
string = data[1]
string = [i for i in string if i != '\n']
zero = string.count('0')
one = string.count('1')
res = abs(zero - one)
print(len(string) - min(zero, one) * 2)


n = int(input())
s = input()
c = [0, 0]
for ch in s:
	if ch == '0':
		c[0] += 1
	else:
		c[1] += 1
print(n - 2 * min(c[0], c[1]))


n = int(input())
shu = input()
a = shu.count('1')
b = shu.count('0')
print(abs(a - b))


n = int(input())
s = input()
k = 0
for i in s:
	if i == '0':
		k += 1
print(abs(n - 2 * k))


def case_of_the_zeros_and_ones(n, a):
	return abs(a.count('1') - a.count('0'))
n = int(input())
s = input()
print(case_of_the_zeros_and_ones(n, s))


n = int(input())
s = input()
c_1 = int()
c_0 = int()
for i in range(n):
	if s[i] == '0':
		c_0 += 1
	else:
		c_1 += 1
if c_0 > c_1:
	print(c_0 - c_1)
else:
	print(c_1 - c_0)


input()
s = input()
(a, b) = (s.count('0'), s.count('1'))
print(max(a, b) - min(a, b))


n = int(input())
s = input()
cnt1 = 0
cnt0 = 0
for i in s:
	if i == '1':
		cnt1 += 1
	else:
		cnt0 += 1
print(n - min(cnt0, cnt1) * 2)


n = int(input())
s = input()
print(n - 2 * min(s.count('0'), n - s.count('0')))


a = int(input())
b = input()
c = b.count('0')
zero = [len(b) - c, c]
print(len(b) - 2 * min(zero))


n = int(input())
str = list(input()[:n])
if str.count('1') == str.count('0'):
	print(0)
else:
	print(abs(str.count('1') - str.count('0')))


n = int(input())
s = input()
on = 0
for x in s:
	if x == '1':
		on += 1
if on < n - on:
	print(n - 2 * on)
else:
	print(2 * on - n)


n = int(input())
a = input()
o = [0] * 2
for i in range(n):
	o[int(a[i])] = o[int(a[i])] + 1
print(abs(o[0] - o[1]))


n = int(input())
tab = list(input())
i = tab.count('1')
j = tab.count('0')
n = n - 2 * min(i, j)
print(n)


n = int(input())
L = list(input())
print(abs(n - 2 * L.count('0')))


import sys
cases = sys.stdin.readline().strip()
string = sys.stdin.readline().strip()
zeroes = 0
ones = 0
for i in range(len(string)):
	if string[i] == '1':
		ones += 1
	else:
		zeroes += 1
operations = min(ones, zeroes)
answer = ones + zeroes - 2 * operations
print(answer)


n = int(input())
data = input()
ans = 0
for i in range(n):
	if data[i] == '0':
		ans += 1
	else:
		ans -= 1
print(abs(ans))


number = input()
n = input()
digit = list()
count_one = 0
count_zero = 0
for i in n:
	if i is '1':
		count_one = count_one + 1
	else:
		count_zero = count_zero + 1
print(abs(count_one - count_zero))


a = int(input())
b = input()
num1 = b.count('0')
num2 = b.count('1')
print(abs(num1 - num2))


n = int(input())
s = input()
s = list(map(int, s))
print(abs(s.count(1) - s.count(0)))


a = int(input())
s = input()
print(len(s) - 2 * min(s.count('0'), s.count('1')))


import math
n = int(input())
arr = input()
nn = sum([1 for i in arr if i == '1'])
print(abs(n - 2 * nn))


n = int(input())
line = str(input())
for i in range(n):
	if line[i] == '0':
		n -= 2
print(abs(n))


def find(s, n):
	stack = []
	for i in s:
		if not stack:
			stack.append(i)
		elif stack[-1] == '1' and i == '0':
			stack.pop()
		elif stack[-1] == '0' and i == '1':
			stack.pop()
		else:
			stack.append(i)
	print(len(stack))
n = int(input())
s = str(input())
find(s, n)


n = int(input())
s = input()
if '1' not in s or '0' not in s:
	print(len(s))
else:
	s = list(s)
	n1 = s.count('1')
	n0 = s.count('0')
	print(n - 2 * min(n1, n0))


n = int(input())
t = input()
a = b = 0
for i in range(0, n):
	if t[i] == '0':
		a += 1
	else:
		b += 1
print(abs(a - b))


a = int(input())
b = input()
if b.count('0') == b.count('1'):
	print(0)
elif b.count('0') > b.count('1'):
	print(b.count('0') - b.count('1'))
elif b.count('0') < b.count('1'):
	print(b.count('1') - b.count('0'))


n = int(input())
s = input()
c0 = s.count('0')
c1 = s.count('1')
x = c0 - c1
if x < 0:
	x = x * -1
print(x)


n = int(input())
ch = str(input())
print(abs(ch.count('0') - ch.count('1')))


n = input()
l = list(input())
print(abs(l.count('0') - l.count('1')))


n = int(input())
l = [i for i in input()]
print(abs(l.count('1') - l.count('0')))


n = int(input())
a = input()
zero = a.count('0')
one = a.count('1')
pary = min(zero, one)
print(max(zero - pary, one - pary))


n = int(input())
l = ' '.join(input()).split()
ones = 0
for i in l:
	if i == '1':
		ones += 1
zeros = n - ones
print(abs(ones - zeros))


n = eval(input())
word = input()
cont1 = 0
cont2 = 0
for i in range(n):
	if word[i] == '0':
		cont1 += 1
	else:
		cont2 += 1
print(abs(cont1 - cont2))


n = int(input())
n_list = list(input())
countone = n_list.count('1')
countzero = n_list.count('0')
print(abs(countone - countzero))


n = int(input())
u = input()
z = 0
k = 0
if n == 1:
	print(1)
else:
	for i in range(n):
		if u[i] == '1':
			z += 1
		else:
			k += 1
	kk = min(z, k)
	uu = max(z, k)
	print(uu - kk)


n = int(input())
str1 = str(input())
ones = str1.count('1')
zeros = str1.count('0')
if ones == zeros:
	print(0)
elif ones > zeros:
	print(ones - zeros)
else:
	print(zeros - ones)


n = int(input())
a = str(input())
n1 = a.count('1')
n2 = a.count('0')
if a.count('10') > 0 or a.count('01') > 0:
	print(abs(n1 - n2))
else:
	print(n)


b = 0
z = int(input())
x = list(map(int, input()))
if x.count(0) > x.count(1):
	b = x.count(0) - x.count(1)
	print(b)
elif x.count(0) < x.count(1):
	b = x.count(1) - x.count(0)
	print(b)
else:
	print(0)


num = input()
string = input()
x = string.count('1')
y = string.count('0')
print(abs(x - y))


n = int(input())
a = input()
print(abs(n - 2 * len(a.replace('0', ''))))


n = int(input())
line = str(input())
zero = 0
one = 0
for i in line:
	if i == '0':
		zero += 1
	else:
		one += 1
if zero > one:
	print(zero - one)
else:
	print(one - zero)


import math
n = input()
s = input()
counter = 0
if s.find('01', int(n)) == -1 and s.find('01', int(n)) == -1:
	print(int(n) - 2 * min(s.count('1', 0, int(n)), s.count('0', 0, int(n))))
else:
	for i in range(0, int(n) - 1):
		if s[i] == '1' and s[i + 1] == '0':
			counter += 1
		elif s[i] == '0' and s[i + 1] == '1':
			counter += 1
		else:
			continue
	print(int(n) - 2 * counter)


n = int(input())
str1 = input()
zeroes = str1.count('0')
ones = str1.count('1')
print(abs(zeroes - ones))


n = int(input())
s = input()
one = 0
zero = 0
for i in s:
	if int(i) == 1:
		one += 1
	else:
		zero += 1
m = min(one, zero)
print(n - 2 * m)


import sys

def add_all(array, idx0, idx1):
	value = 0
	for idx in range(idx0, idx1 + 1):
		value += array[idx]
	return value
n = input()
string = input()
count = 0
for char in string:
	if char == '0':
		count -= 1
	else:
		count += 1
print(abs(count))


n = int(input())
l1 = input()
a = l1.count('1')
b = l1.count('0')
while a > 0 and b > 0:
	a -= 1
	b -= 1
print(a + b)


n = int(input())
st = input()
l = list(map(st.count, ['0', '1']))
print(n - 2 * min(l[0], l[1]))


n = int(input())
s = input()
k0 = s.count('0')
k1 = s.count('1')
print(abs(k1 - k0))


R = lambda : list(map(int, input().split()))
input()
s = input()
n = len(s)
n0 = s.count('0')
n1 = s.count('1')
print(max(n - n0 * 2, n - n1 * 2))


n = int(input())
s = input()
zeros = 0
um = 0
for i in range(n):
	if s[i] == '0':
		zeros += 1
	if s[i] == '1':
		um += 1
print(abs(zeros - um))


comprimento = int(input())
string = input()
listab = list(string)
q1 = listab.count('0')
q2 = listab.count('1')
if q1 >= q2:
	num = q1 - q2
	print(num)
elif q2 >= q1:
	num = q2 - q1
	print(num)


n = int(input())
s = input()
l = list(s)
a = l.count('1')
b = l.count('0')
print(abs(a - b))


n = int(input())
s = input()
(p1, p2) = (s.count('0'), s.count('1'))
p = abs(p1 - p2)
print(p)


n = int(input())
f = input()
print(abs(f.count('0') - f.count('1')))


n = int(input())
testStr = input()
ones = testStr.count('1')
zeroes = testStr.count('0')
print(abs(ones - zeroes))


n = int(input())
line = input()
zeroes = 0
ones = 0
for i in line:
	if i == '1':
		ones += 1
	else:
		zeroes += 1
print(ones + zeroes - 2 * min(ones, zeroes))


n = int(input())
a = list(input())
s = 0
f = 0
for i in range(n):
	if a[i] == '1':
		s += 1
	else:
		f += 1
print(abs(s - f))


i = input()
s = input()
c = len(s)
if s.count('0') >= s.count('1'):
	print(c - s.count('1') * 2)
else:
	print(c - s.count('0') * 2)


x = int(input())
emon = input()
a = emon.count('0')
b = emon.count('1')
if a >= b:
	print(a - b)
else:
	print(b - a)


z = input
from math import gcd
n = int(z())
l = z()
o = l.count('1')
e = l.count('0')
print(abs(o - e))


n = int(input())
string = [int(x) for x in input()]
stack = []
for item in string:
	if len(stack):
		if stack[-1] == item ^ 1:
			stack.pop()
		else:
			stack.append(item)
	else:
		stack.append(item)
print(len(stack))


tam = int(input())
num = str(input())
ones = 0
zeros = 0
for i in num:
	if i == '1':
		ones += 1
	else:
		zeros += 1
print(tam - min(ones, zeros) * 2)


n = int(input())
string = str(input())
ones = string.count('1')
zeroes = string.count('0')
print(max(ones, zeroes) - min(ones, zeroes))


n = eval(input(''))
o = str(input(''))
test2 = [int(d) for d in str(o)]
ones = 0
zeros = 0
i = 0
while i <= len(test2) - 1:
	if test2[i] == 0:
		zeros += 1
	if test2[i] == 1:
		ones += 1
	i += 1
x = min(ones, zeros)
p = n - 2 * x
print(p)


x = int(input())
n = input()
num_1 = n.count('1')
num_0 = n.count('0')
if num_1 == num_0:
	print(0)
elif num_1 > num_0:
	print(num_1 - num_0)
else:
	print(num_0 - num_1)


n = int(input())
s = input()
x1 = 0
x0 = 0
for i in s:
	if i == '0':
		x0 += 1
	else:
		x1 += 1
print(abs(x1 - x0))


from math import ceil

def solve():
	n = int(input())
	s = input()
	print(len(s) - min(s.count('0'), s.count('1')) * 2)
solve()


length = input()
string = input()
binary_map = {}
for letter in string:
	if letter == '0':
		if '0' in binary_map:
			binary_map['0'] += 1
		else:
			binary_map['0'] = 1
	elif '1' in binary_map:
		binary_map['1'] += 1
	else:
		binary_map['1'] = 1
best_case = 0
if '0' in binary_map and '1' in binary_map:
	best_case = min(binary_map['0'], binary_map['1'])
print(int(length) - best_case * 2)


n = int(input())
a = list(input())
num = 0
for i in range(n):
	if '0' in a[i]:
		num += 1
num1 = n - num
ans = abs(num1 - num)
print(ans)


x = int(input())
s = str(input())
cnt = 0
for i in range(0, x):
	cnt += int(s[i])
print(abs(2 * cnt - x))


n = int(input())
zerone = [int(i) for i in input()]
one = zerone.count(1)
zero = zerone.count(0)
print(abs(one - zero))


n = int(input())
sp = list(input())
t = [0, 0]
for i in range(n):
	t[int(sp[i])] += 1
print(max(t) - min(t))


n = int(input())
s = input()
n1 = 0
n0 = 0
for i in s:
	if i == '1':
		n1 = n1 + 1
	else:
		n0 = n0 + 1
print(abs(n1 - n0))


class Stack:

	def __init__(self):
		self.items = []

	def isEmpty(self):
		return self.items == []

	def push(self, item):
		self.items.append(item)

	def pop(self):
		return self.items.pop()

	def peek(self):
		return self.items[len(self.items) - 1]

	def size(self):
		return len(self.items)
s = Stack()
m = int(input())
k = input()
for i in range(0, len(k)):
	if not s.isEmpty() and s.peek() != k[i]:
		s.pop()
	else:
		s.push(k[i])
r = ''.join(s.items)
print(len(r))


t = int(input())
a = input()
x = a.count('1')
y = a.count('0')
z = min(x, y)
print(t - 2 * z)


k = i = 0
l = n = int(input())
c = input()
while n > 0:
	if c[i] == '1':
		k += 1
	n -= 1
	i += 1
print(abs(l - 2 * k))


input()
line = input()
res = [0] * 2
for i in range(len(line)):
	res[int(line[i])] += 1
print(len(line) - 2 * min(res[0], res[1]))


u = int(input())
a = input()
c = []
b = []
for i in a:
	if i == '0':
		c.append(1)
	else:
		b.append(1)
j = c.count(1)
k = b.count(1)
if j == k:
	print('0')
elif j < k:
	j = k - j
	print(j)
else:
	k = j - k
	print(k)


from sys import stdin
import math
n = int(stdin.readline())
st = stdin.readline()
res0 = 0
res1 = 0
for i in range(0, n):
	if st[i] == '0':
		res0 += 1
	else:
		res1 += 1
print(int(math.fabs(res0 - res1)))


n = int(input())
a = input()
(hasil0, hasil1) = (0, 0)
for i in a:
	if i == '1':
		hasil1 += 1
	else:
		hasil0 += 1
if hasil1 > hasil0:
	print(hasil1 - hasil0)
else:
	print(hasil0 - hasil1)


n = int(input())
l = input()
from collections import Counter
c = Counter(l)
if c.most_common()[:-1 - 1:-1][0][1] == n:
	print(n)
	exit()
print(n - 2 * c.most_common()[:-1 - 1:-1][0][1])


size = int(input())
word = input()
soma = 0
for i in range(size):
	if word[i] == '1':
		soma += 1
	else:
		soma -= 1
print(abs(soma))


n = int(input())
m = input()
print(max(m.count('0'), m.count('1')) - min(m.count('0'), m.count('1')))


n = int(input())
st = input()
diff = 0
for ch in st:
	if ch == '1':
		diff += 1
	else:
		diff -= 1
print(abs(diff))


n = int(input())
s = input()
c = s.count('0')
d = s.count('1')
c = min(c, d)
print(n - 2 * c)


n = int(input())
s = input()
if set(s) == 1:
	print(n)
else:
	zero = [x for x in s if x == '0']
	ones = [x for x in s if x == '1']
	if len(zero) > len(ones):
		n = n - len(ones) * 2
	else:
		n = n - len(zero) * 2
print(n)


n = int(input())
s = list(map(int, list(input()))) + [-1]
p = -1
c = 1
c1 = 0
c2 = 0
for i in range(n + 1):
	if p == s[i]:
		c += 1
	else:
		if p == 0:
			c1 += c
		elif p == 1:
			c2 += c
		p = s[i]
		c = 1
print(abs(c1 - c2))


n = int(input())
s = str(input())
c = 0
t = s.count('1')
print(abs(2 * t - n))


length = int(input())
s = str(input())
cnt0 = 0
cnt1 = 0
for c in s:
	if c == '0':
		cnt0 += 1
	else:
		cnt1 += 1
print(abs(cnt0 - cnt1))


n = int(input())
k = input()
t = min(k.count('0'), k.count('1'))
print(n - 2 * t)


num = int(input())
s = input()
if s.count('1') >= s.count('0'):
	print(s.count('1') - s.count('0'))
else:
	print(s.count('0') - s.count('1'))


n = int(input())
number = input()
l = list()
for d in number:
	if l and l[-1] != d:
		l.pop(-1)
	else:
		l.append(d)
print(len(l))


n = int(input())
string_01 = input()
um = 0
zero = 0
for i in range(n):
	if string_01[i] == '0':
		um += 1
	else:
		zero += 1
if um > zero:
	print(um - zero)
else:
	print(zero - um)


a = int(input())
b = list(input())
c = b.count('0')
d = a - c
print(abs(c - d))


a = int(input())
b = input()
z = b.count('0')
on = a - z
print(abs(on - z))


str_length = int(input())
zeros_ones = str(input())
print(abs(str_length - 2 * zeros_ones.count('0')))


n = int(input())
s = str(input())
if s.count('1') == s.count('0'):
	ans = 0
else:
	ans = abs(s.count('1') - s.count('0'))
print(ans)


n = int(input())
len_n = str(input())
print(abs(len_n.count('1') - len_n.count('0')))