Sergey is testing a next-generation processor. Instead of bytes the processor works with memory cells consisting of n bits. These bits are numbered from 1 to n. An integer is stored in the cell in the following way: the least significant bit is stored in the first bit of the cell, the next significant bit is stored in the second bit, and so on; the most significant bit is stored in the n-th bit.

Now Sergey wants to test the following instruction: "add 1 to the value of the cell". As a result of the instruction, the integer that is written in the cell must be increased by one; if some of the most significant bits of the resulting number do not fit into the cell, they must be discarded.

Sergey wrote certain values ​​of the bits in the cell and is going to add one to its value. How many bits of the cell will change after the operation?


-----Input-----

The first line contains a single integer n (1 ≤ n ≤ 100) — the number of bits in the cell.

The second line contains a string consisting of n characters — the initial state of the cell. The first character denotes the state of the first bit of the cell. The second character denotes the second least significant bit and so on. The last character denotes the state of the most significant bit.


-----Output-----

Print a single integer — the number of bits in the cell which change their state after we add 1 to the cell.


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

Output
3

Input
4
1111

Output
4



-----Note-----

In the first sample the cell ends up with value 0010, in the second sample — with 0000.

Difficulty: EASY

Solutions:
N = int(input())
S = input()
flg = True
ans = 0
for s in S:
	if flg:
		if s == '0':
			ans += 1
			flg = False
		elif s == '1':
			ans += 1
			flg = True
print(ans)


n = int(input())
a = input()
c = 1
ans = 0
for i in range(n):
	cur = int(a[i]) + c
	ans += cur % 2 != int(a[i])
	c = cur // 2
print(ans)


n = int(input())
s = input()
res = s.find('0')
print(n if res == -1 else res + 1)


n = input()
print((input()[:-1] + '0').index('0') + 1)


import math
n = int(input())
d = list(input())
old_num_bin = []
for i in range(n):
	old_num_bin.append(int(d[n - i - 1]))
old_num_value = 0
for i in range(n):
	old_num_value += int(d[i]) * pow(2, i)
new_num_value = old_num_value + 1
new_num_bin = list(bin(new_num_value)[2:])
if len(new_num_bin) < n:
	append_index = n - len(new_num_bin)
	for i in range(append_index):
		new_num_bin.insert(0, 0)
elif len(new_num_bin) > n:
	append_index = len(new_num_bin) - n
	new_num_bin = list(new_num_bin[append_index:])
k = 0
for i in range(n):
	if int(old_num_bin[i]) != int(new_num_bin[i]):
		k += 1
print(k)


n = int(input())
s = str(input())
x = 0
for i in range(n):
	x += 1
	if s[i] != '1':
		break
print(x)


import re
import sys
exit = sys.exit
from bisect import bisect_left as bsl, bisect_right as bsr
from collections import Counter, defaultdict as ddict, deque
from functools import lru_cache
cache = lru_cache(None)
from heapq import *
from itertools import *
from math import inf
from pprint import pprint as pp
enum = enumerate
ri = lambda : int(rln())
ris = lambda : list(map(int, rfs()))
rln = sys.stdin.readline
rl = lambda : rln().rstrip('\n')
rfs = lambda : rln().split()
cat = ''.join
catn = '\n'.join
mod = 1000000007
d4 = [(0, -1), (1, 0), (0, 1), (-1, 0)]
d8 = [(-1, -1), (0, -1), (1, -1), (-1, 0), (1, 0), (-1, 1), (0, 1), (1, 1)]
n = ri()
s = rl()
ans = 0
for x in s:
	ans += 1
	if x == '0':
		break
print(ans)


def main():
	a = int(input())
	b = input()
	bt = b
	b = list(b)
	c = reversed(b)
	cs = ''.join(map(str, c))
	ci = int(cs, 2)
	ci += 1
	z = bin(ci)[2:]
	z = list(reversed(z))
	z = map(str, z)
	z = ''.join(z)
	co = 0
	bt = bt + '0' * (101 - len(bt))
	z = z + '0' * (101 - len(z))
	for x in range(len(z)):
		if z[x] != bt[x]:
			co += 1
			pass
		pass
	if co > a:
		co -= 1
	print(co)
	pass
main()


n = int(input())
s = input()
kek = 0
rofl = 1
while rofl < n and s[rofl] == '1':
	kek += 1
	rofl += 1
if s[0] == '0':
	print(1)
else:
	print(min(rofl + 1, n))


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

def rints():
	return list(map(int, input().split()))
n = rint()
bits = input()
bits = bits[::-1]
before = int(bits, 2)
after = (before + 1) % 2 ** n
print(bin(before ^ after).count('1', 2))


import itertools as ittls
from collections import Counter
import re
import math

def sqr(x):
	return x * x

def inputarray(func=int):
	return map(func, input().split())
N = int(input())
A = list(input())
i = 0
while i < len(A) and A[i] == '1':
	i = i + 1
print(min(i + 1, len(A)))


n = int(input())
s = input()
carry = 1
ans = [0]
if s[0] == '0':
	print(1)
else:
	for i in range(1, n):
		if s[i] == '0' and carry == 1:
			ans.append(1)
			carry = 0
		elif s[i] == '0' and carry == 0:
			ans.append(0)
			carry = 0
		elif s[i] == '1' and carry == 1:
			ans.append(0)
			carry = 1
		elif s[i] == '1' and carry == 0:
			ans.append(1)
			carry = 0
	c = 0
	for i in range(n):
		if int(s[i]) != ans[i]:
			c += 1
	print(c)


def main():
	n = input()
	s = input()
	c = 0
	for x in s:
		c += 1
		if x == '0':
			break
	print(c)
main()


n = int(input())
bits = input()
bits = [int(i) for i in bits]
state = 0
add_bit = 1
for x in bits:
	x += add_bit
	if x == 2:
		state += 1
		add_bit = 1
		continue
	if x == 1:
		state += 1
		add_bit = 0
		break
print(state)


def binary(n):
	return bin(n).replace('0b', '')

def dec(n):
	return int(n, 2)
a = int(input())
b = input()
b = b[::-1]
l = len(b)
c = dec(b) + 1
d = str(binary(c))
m = len(d)
b = b[::-1]
d = d[::-1]
cnt = 0
if l > m:
	for i in range(m):
		if b[i] != d[i]:
			cnt += 1
	for i in range(m, l):
		if b[i] != '0':
			cnt += 1
else:
	for i in range(l):
		if b[i] != d[i]:
			cnt += 1
print(cnt)


n = int(input())
l = list(map(int, input()))
s = 0
for i in range(len(l)):
	s += 2 ** i * l[i]
x = bin(s + 1)[2:]
y = [0] * (n - len(x))
z = list(map(int, x))
f = y + z
f.reverse()
t = 0
for i in range(n):
	t += abs(l[i] - f[i])
print(t)


n = int(input())
string = input()
x = 1
for i in range(n):
	if string[i] == '1':
		x += 1
	else:
		print(x)
		exit()
print(x - 1)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
import random
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 list(map(int, sys.stdin.readline().split()))

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

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 pe(s):
	return print(str(s), file=sys.stderr)

def main():
	n = I()
	s = S()
	for i in range(n):
		if s[i] == '0':
			return i + 1
	return n
print(main())


n = int(input())
a = input()
res = 0
last = '1'
for i in range(n):
	if last == '1':
		res += 1
	last = a[i]
	if last == '0':
		break
print(res)


n = int(input())
s = input()
print(min(len(s.split('0')[0]) + 1, n))


n = int(input())
ls = [int(u) for u in input()]
if 0 in ls:
	print(ls.index(0) + 1)
else:
	print(len(ls))


n = int(input())
s = input()
v = list((int(x) for x in s))
c = 0
for i in range(len(v)):
	c += 1
	if not v[i]:
		break
print(c)


n = int(input())
st = input()
num = 0
for i in range(n):
	if st[i] == '1':
		num += 2 ** i
num = num + 1
b = bin(num).replace('0b', '')
b = b[::-1]
ans = 0
l = min(n, len(b))
for i in range(l):
	if st[i] != b[i]:
		ans += 1
for i in range(l, n):
	if st[i] != '0':
		ans = ans + 1
print(ans)


n = int(input())
s = input()
cnt = 0
for x in s:
	if x == '1':
		cnt += 1
	else:
		break
print(min(n, cnt + 1))


n = int(input())
arr = list(map(int, input()))
ans = 0
carry = 0
for i in range(n):
	if arr[i] == 1:
		arr[i] = 0
		ans += 1
	else:
		arr[i] = 1
		ans += 1
		break
print(ans)


input()
haveone = 0
changed = 0
binarynum = input()
if binarynum[0] == '1':
	haveone = 1
changed = 1
for i in binarynum[1:]:
	if haveone:
		if i == '0':
			haveone = 0
		changed += 1
	else:
		break
print(changed)


n = int(input())
s = input()[::-1]
s1 = bin(int(s, 2) + 1)[2:].zfill(n)[-n:]
cnt = 0
for i in range(n):
	if s[i] != s1[i]:
		cnt += 1
print(cnt)


m = int(input())
count = 0
x = input()
for i in range(m):
	if x[i] == '1':
		count += 1
	else:
		count += 1
		break
print(count)


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


x = int(input())
cell = input()
cell2 = ''
for i in cell:
	cell2 = i + cell2
cell3 = bin(int(cell2, 2) + 1)
cell4 = cell3[2:]
cell5 = '0' * (x - len(cell4))
for i in cell4:
	cell5 = i + cell5
cell6 = cell5[:x]
sa = 0
for i in range(x):
	if cell6[i] != cell[i]:
		sa += 1
print(sa)


n = int(input())
s = input()
cnt = 0
for i in range(n):
	if s[i] == '0':
		cnt += 1
		break
	cnt += 1
print(cnt)


n = int(input())
b = input()
if set(list(b)) == {'1'}:
	print(n)
elif b[0] == '0':
	print(1)
else:
	b = b.replace('0', ' ').split()
	print(len(b[0]) + 1 if b else 1)


k = int(input())
text = input()
rez = 0
for i in text:
	if i != '0':
		rez += 1
	else:
		rez += 1
		break
print(rez)


n = int(input())
st = input()
carry = 1
nums = 0
for i in range(n):
	if st[i] == '1' and carry == 1:
		carry = 1
		nums += 1
	elif st[i] == '0' and carry == 1:
		carry = 0
		nums += 1
	elif st[i] == '1' and carry == 0:
		carry = 0
	else:
		carry = 0
print(nums)


input()
r = 0
for x in input():
	if x == '1':
		r += 1
	else:
		r += 1
		break
print(r)


n = int(input())
inp = input()
res = 0
for i in inp:
	if i != '1':
		break
	res += 1
print(min(n, res + 1))


(n, m) = (int(input()), int(input()[::-1], 2))
print(bin(m ^ (m + 1) % 2 ** n).count('1'))


n = int(input())
c = input()[::-1]
nc = format(int(c, 2) + 1, f'0{len(c)}b')
if len(nc) > len(c):
	nc = nc[1:]
o = 0
for (cb, ncb) in zip(c, nc):
	if cb != ncb:
		o += 1
print(o)


n = int(input())
try:
	print(input().index('0') + 1)
except ValueError:
	print(n)


def solve(s, n):
	s = ''.join(reversed(s))
	res = bin(int(s, 2) + int('1', 2))[2:]
	count = 0
	if len(res) < n:
		res = '0' * (n - len(res)) + res
	elif len(res) > n:
		res = res[len(res) - n:]
	for i in range(len(s)):
		if s[i] != res[i]:
			count += 1
	return count

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


n = int(input())
l = list(input())
if '0' in l:
	print(l.index('0') + 1)
else:
	print(n)


n = int(input())
a = input()
b = bin(int(a[::-1], 2) + 1)[2:].zfill(n)[::-1]
ans = 0
for i in range(n):
	if a[i] != b[i]:
		ans += 1
print(ans)


n = int(input())
s = [int(i) for i in input()]
count = 0
for i in s:
	if i == 0:
		break
	else:
		count += 1
print(min(n, count + 1))


import sys
sys.setrecursionlimit(10 ** 5 + 1)
inf = int(10 ** 20)
max_val = inf
min_val = -inf
RW = lambda : sys.stdin.readline().strip()
RI = lambda : int(RW())
RMI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
RWI = lambda : [x for x in sys.stdin.readline().strip().split()]
lens = RI()
given = RW()
given = given.split('0')
answer = min(len(given[0]) + 1, lens)
print(answer)


n = int(input())
a = input()
t = 0
for i in a:
	if i == '1':
		t += 1
	elif i == '0':
		t += 1
		print(t)
		break
else:
	print(t)


def turnBitIntoInteger(bit, begin, end):
	i = 1
	sum = 0
	while begin < end:
		sum += int(bit[begin]) * i
		i = i * 2
		begin += 1
	return sum
num = int(input())
str = input()
inhand = '1'
count = 0
for i in str:
	if i == '0':
		if i != inhand:
			inhand = '0'
			count += 1
			i = '1'
	elif i == inhand:
		inhand = '1'
		count += 1
		i = '0'
	else:
		inhand = '0'
		count += 0
print(count)


input()
a = input()
print(a.index('0') + 1 if '0' in a else len(a))


n = int(input())
S = input()
r = 1
a = 0
for s in S:
	if s == '0' and r == 1:
		a += 1
		r = 0
	if s == '1' and r == 1:
		a += 1
		r = 1
print(a)


n = int(input())
k1 = input()
s = '0b' + k1[::-1]
s1 = '0b' + '0' * (n - 1) + '1'
k = bin(int(s, 2) + int(s1, 2))
k = k.lstrip('0b')
k = ('0' * abs(n - len(k)) + k)[::-1]
ans = 0
for i in range(n):
	if k1[i] != k[i]:
		ans += 1
print(ans)


n = int(input())
string = input()
count = 0
for i in range(len(string)):
	if string[i] == '1':
		count += 1
	else:
		count += 1
		break
print(count)


(x, n) = (int(input()), 1)
y = list(input())
for i in y:
	if i == '1':
		n += 1
	else:
		break
print(min(n, x))


n = input()
s = input()
count = 0
for i in s:
	count += 1
	if i == '0':
		break
print(count)


NumofInpt = int(input())
Inpt = input()
MainCount = 1
Count = 0
for I in range(NumofInpt):
	strInpt = Inpt
	if strInpt[Count] == '1':
		MainCount += 1
	else:
		break
	Count += 1
if MainCount > NumofInpt:
	MainCount -= 1
print(MainCount)


n = int(input())
a = str(input())
for i in range(n):
	if a[i] == '0':
		print(i + 1)
		break
	elif i == n - 1:
		print(n)


n = int(input())
s = input()
num = s[::-1]
ans = 0
rem = 1
while num:
	x = int(num) % 10
	num = num[:-1]
	if x == 1 and rem == 1:
		ans += 1
		rem = 1
	elif x == 0 and rem == 1:
		ans += 1
		rem = 0
	else:
		rem = 0
print(ans)


number = 0
binary = ''
counter = 0
n1 = input()
n = input()
n = n[::-1]
size = len(n)
for i in n:
	size -= 1
	number1 = int(i) * 2 ** size
	number += number1
number += 1
binary = bin(number).replace('0b', '')
for i in range(len(n) - len(binary)):
	binary = '0' + binary
n = n[::-1]
for i in range(len(n) - 1, -1, -1):
	if n[i] != binary[len(binary) - (i + 1)]:
		counter += 1
print(counter)


(n, cell, i) = (int(input()), list(map(int, input().strip())), 0)
while i < n - 1 and cell[i]:
	i += 1
print(i + 1)


n = int(input())
a = input()
r = 1
for i in range(n):
	if a[i] == '1':
		r += 1
	else:
		break
if i == n - 1 and a[i] == '1':
	r -= 1
print(r)


n = int(input())
a = input()
for i in range(n):
	if a[i] == '1':
		continue
	else:
		print(i + 1)
		exit()
print(n)


num = int(input())
s = input()[::-1]
n = bin(int(s, 2) + 1)
ss = n[2:]
ans = 0
if len(ss) < len(s):
	ss = '0' * (len(s) - len(ss)) + ss
elif len(ss) > len(s):
	ss = ss[1:]
for (i, j) in zip(s, ss):
	if i != j:
		ans += 1
print(ans)


n = int(input())
st = input()[::-1]
s = int(st, 2)
s += 1
ans = 0
for i in range(n):
	if (s % 2 == 1) ^ (st[n - i - 1] == '1'):
		ans += 1
	s //= 2
print(ans)


N = int(input())
S = input()[::-1]
x = int(S, 2) + 1
Sp = bin(x)[2:].zfill(N)[-N:]
print(sum((a != b for (a, b) in zip(S, Sp))))


n = input()
s = [int(i) for i in input()]
count = 0
add = 1
for i in s:
	if i == 1 and add == 1:
		count += 1
	elif i == 1 and add == 0:
		count += 0
	elif i == 0 and add == 0:
		count += 0
	elif i == 0 and add == 1:
		count += 1
		add = 0
print(count)


n = int(input())
c = str(input())
if c[0] == 0:
	print(1)
elif '0' not in c:
	print(n)
else:
	x = c.split('0')[0]
	print(len(x) + 1)


input()
n = input()
if '0' in n:
	print(n.index('0') + 1)
else:
	print(len(n))


def solve(n, s):
	x = 0
	for i in s:
		if i == '1':
			x += 1
		else:
			x += 1
			break
	return x

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


import math
n = int(input())
str = input()
res = ['' for i in range(n)]
b = True
for i in range(n):
	if str[i] == '0':
		res[i] = '1'
		for j in range(i):
			res[j] = '0'
		b = False
		for j in range(i + 1, n):
			res[j] = str[j]
		break
if b:
	print(n)
else:
	total = 0
	for i in range(n):
		if res[i] != str[i]:
			total += 1
	print(total)


n = int(input())
x = ''.join(list(reversed(input())))
k = int(x, 2)
x = str(bin(k))
y = str(bin(k + 1))
x = ''.join(list(reversed(x)))
y = ''.join(list(reversed(y)))
ans = 0
for i in range(len(x)):
	if x[i] != y[i]:
		ans += 1
	if x[i] == 'b':
		break
print(min(n, ans))


n = int(input())
s = input()
c = ''
for i in range(n):
	if s[i] != '1':
		c += '1'
		i += 1
		break
	else:
		c += '0'
while i < n:
	c += s[i]
	i += 1
cnt = 0
for i in range(n):
	if s[i] != c[i]:
		cnt += 1
print(cnt)


n = int(input())
l = list(input())
c = 0
for x in l:
	if int(x) == 0:
		c += 1
		break
	else:
		c += 1
print(c)


cells = int(input())
cell = input()
cont = 0
for x in cell:
	if x == '1':
		cont += 1
	else:
		cont += 1
		break
print(cont)


i = int(input())
str = str(input())
for x in range(0, i):
	if str[x] == '0':
		print(x + 1)
		exit()
print(i)


n = int(input())
num = input()
idx = num.find('0')
if idx == -1:
	print(str(n))
else:
	print(str(idx + 1))


n = int(input())
line = str(input())
tar = 0
for i in range(n):
	tar += 1
	if line[i] == '0':
		break
print(tar)


n = int(input())
s = input()
f = s.find('0')
if f == -1:
	print(n)
else:
	print(f + 1)


import sys
input = sys.stdin.readline
n = int(input())
s = input().strip()
ans = 0
for x in s:
	if x == '1':
		ans += 1
	else:
		break
print(min(ans + 1, n))


n = int(input())
cell = str(input())
if '0' in cell:
	print(cell.index('0') + 1)
else:
	print(n)


n = int(input())
s = input()
c = 1
t = 0
for c in s:
	t += 1
	if c == '0':
		c = 0
		break
print(t)


n = int(input())
l = input()
count = 0
for i in l:
	count += 1
	if i == '0':
		print(count)
		break
else:
	print(count)


n = int(input())
k = input()
amount = 0
for elem in k:
	amount += 1
	if elem == '0':
		break
print(amount)


a = int(input())
b = int('0b' + input()[::-1], 2)
c = (b + 1) % 2 ** a
print(bin(b ^ c).count('1'))


x = int(input())
a = input()
t = 0
for i in range(len(a)):
	if a[i] == '0':
		t = t + 1
		break
	else:
		t = t + 1
print(t)


import re
cv = 0
s2 = ''
n = int(input())
s1 = input()
for x in range(n):
	if int(s1[x]) == 1:
		s2 = s2 + '0'
	else:
		s2 = s2 + '1'
		s2 = s2 + s1[x + 1:n]
		break
for x in range(n):
	if re.match(s1[x], s2[x]):
		cv = cv + 1
print(n - cv)


x = int(input())
a = list(map(int, input()))
p = 1
j = 0
for i in range(x):
	if a[i] == 1 and p == 1:
		a[i] = 0
		j += 1
	elif a[i] == 0 and p == 1:
		a[i] = 1
		p = 0
		j += 1
print(j)


import sys
input = sys.stdin.readline

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

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

def primefs(n):
	primes = {}
	while n % 2 == 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	while x != link[x]:
		x = link[x]
	return x

def union(x, y, size, link):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(1000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().split()))
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
n = int(input())
string = input()
ans = 0
string = string[::-1]
for i in range(1, n + 1):
	if string[-i] == '1':
		ans += 1
	else:
		ans += 1
		break
print(ans)


from sys import stdin

def main():
	n = int(stdin.readline().strip())
	s = stdin.readline().strip()
	return sum((a != b for (a, b) in zip(s, '{:b}'.format(int(s[::-1], 2) + 1)[::-1])))
print(main())


n = int(input())
a = input()
b = a[::-1]
c = int(b, 2) + 1
z = bin(c)
z = z[2:]
str(z)
if len(z) < n:
	z = '0' * (n - len(z)) + z
elif len(z) > n:
	z = z[len(z) - n:]
count = 0
for i in range(n):
	if z[i] != b[i]:
		count += 1
print(count)


trash = int(input())
s = str(input())
count = 1
for i in range(0, len(s) - 1):
	if s[i] == '1':
		count += 1
	else:
		break
print(count)


a = int(input())
b = input()
n = []
l = []
for i in b:
	n.append(int(i))
	l.append(int(i))
for i in range(len(n)):
	if n[i] == 0:
		n[i] = 1
		break
	else:
		n[i] = 0
k = 0
for i in range(len(l)):
	if l[i] != n[i]:
		k += 1
print(k)


n = int(input())
s = input()
y = 0
for i in range(0, len(s)):
	if s[i] == '1':
		y += 1
	else:
		y += 1
		break
print(y)


n = int(input())
bit = input()
print(n if bit.find('0') == -1 else bit.find('0') + 1)


n = int(input())
s = list(input())
ans = 0
for i in range(len(s)):
	if s[i] == '1':
		ans += 1
	else:
		break
print(min(ans + 1, n))


from sys import stdin, stdout
input = stdin.readline
n = int(input())
s = input()[:-1]
ans = 0
for i in s:
	if i == '1':
		ans += 1
	else:
		break
stdout.write(str(min(n, ans + 1)))


n = int(input())
s = input()
if s[0] == '0':
	print(1)
elif '0' in s:
	a = s.index('0')
	print(len(s[0:a + 1]))
else:
	print(n)


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


_ = int(input())
n = list(input())
ans = 0
for i in n:
	if int(i):
		ans += 1
	else:
		break
if ans != len(n):
	print(ans + 1)
else:
	print(ans)


n = int(input())
s = input()
ans = 1
for i in range(len(s)):
	if s[i] == '1':
		ans += 1
	else:
		print(ans)
		exit()
if ans > len(s):
	print(ans - 1)


N = int(input())
L = list(input())
Carry = 1
count = 0
for i in range(N):
	if L[i] == '1' and Carry == 1:
		L[i] = '0'
		count += 1
	elif L[i] == '0' and Carry == 1:
		L[i] = '1'
		Carry = 0
		count += 1
print(count)


n = int(input())
num = input()[-1::-1]
value = int('0b' + num, 2)
value += 1
numm = bin(value).split('b')[1][-n::+1]
length = len(numm)
if length != n:
	numm = '0' * (n - length) + numm
count = 0
for i in range(n):
	if numm[i] != num[i]:
		count += 1
print(count)


def dec_to_bin(x):
	return int(bin(x)[2:])

def count_s(r, i):
	index = 0
	c = 0
	for j in r:
		if j != i[index]:
			c = c + 1
		index = index + 1
	return c
nstr = input()
n = int(nstr)
istr = input()
l = len(istr)
iistr = istr[::-1]
no = int(iistr, 2)
no = no + 1
rstr = str(dec_to_bin(no))
rstr = rstr[::-1]
for j in range(n - len(str(dec_to_bin(no)))):
	rstr = rstr + '0'
rstr = rstr[:l]
print(count_s(rstr, istr))


__author__ = '$'
import sys
try:
	while True:
		n = int(input())
		val = list(input())
		ans = 0
		r = 1
		for i in range(n):
			val[i] = ord(val[i]) - ord('0')
			ans += 1
			r = (val[i] + r) // 2
			if r == 0:
				break
		print(ans)
except EOFError:
	pass


n = int(input())
s = input()
v = int(s[::-1], 2) + 1
res = bin(v)[2:].zfill(n)[::-1][:n]
ans = 0
for i in range(n):
	if s[i] != res[i]:
		ans += 1
print(ans)


n = int(input())
s = input()
swaps = 0
k = 0
for i in range(len(s)):
	if int(s[i]) == 0:
		k += 1
		break
	k += 1
print(k)


n = int(input())
a = input()
print(min(n, len(a) - len(a.lstrip('1')) + 1))


n = int(input())
s = list(input())
total = 0
for x in range(n):
	if s[x] == '1':
		total += 2 ** x
total += 1
k = list(str(bin(total))[2:])
k.reverse()
k = k[:n]
while len(k) < n:
	k.append(0)
ans = 0
for x in range(n):
	ans += int(k[x]) ^ int(s[x])
print(ans)


n = int(input())
e = input()
e = e[::-1]
q = len(e) - 1
a = 0
p = ''
for i in range(0, n):
	s = 2 ** q
	if int(e[i]) > 0:
		a += s
	q -= 1
a += 1
while a > 0:
	p += str(a % 2)
	a //= 2
p = p[::-1]
p = '0' * (len(e) - len(p)) + p
a = 0
if len(e) < len(p):
	e = '1' + e
for y in range(0, len(e)):
	if e[y] != p[y]:
		a += 1
print(a)


total = input()
data = input()
l = data.find('0')
print(len(data) if l == -1 else l + 1)


n = int(input())
k = input().lstrip('1')
print([n - len(k) + 1, n][not len(k)])


n = int(input())
q = input()
s = [int(q[i]) for i in range(len(q))]
s1 = s[:]
rest = 1
for i in range(n):
	rest = s[i] + rest
	s[i] = rest % 2
	rest = rest // 2
q = [s[i] ^ s1[i] for i in range(n)]
print(sum(q))


def main():
	n = input()
	s = list(map(int, input()))
	t = list(s)
	c = 1
	for i in range(len(t)):
		if c == 0:
			break
		t[i] += 1
		if t[i] == 2:
			t[i] = 0
			c = 1
		else:
			c = 0
	res = 0
	for i in range(len(t)):
		res += t[i] != s[i]
	print(res)

def __starting_point():
	main()
__starting_point()


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_intList_from_str = lambda : list(map(int, list(sys.stdin.readline().strip())))
get_charList_from_str = lambda : list(sys.stdin.readline().strip())
get_char_list = lambda : sys.stdin.readline().strip().split()
get_int = lambda : int(sys.stdin.readline())
pt = lambda x: sys.stdout.write(str(x))
n = get_int()
s1 = get_string()
s2 = ''
carry = '1'
for i in range(n):
	if carry == '1' and s1[i] == '1':
		s2 += '0'
		carry = '1'
	elif carry == '1' and s1[i] == '0' or (carry == '0' and s1[i] == '1'):
		s2 += '1'
		carry = '0'
	else:
		s2 += '0'
		carry = '0'
count = 0
for i in range(n):
	if s2[i] != s1[i]:
		count += 1
print(count)


n = int(input())
li = list(input())
for i in range(n):
	if li[i] == '0':
		print(i + 1)
		exit(0)
else:
	print(n)


def AddCountChanges(cell):
	k = 0
	for bit in cell:
		if bit == '1':
			k += 1
		else:
			k += 1
			break
	return k
n = input()
cell = input()
print(AddCountChanges(cell))


input()
s = input()
print(s.index('0') + 1 if '0' in s else len(s))


n = int(input())
m = str(input())
j = 0
while j < n and m[j] == '1':
	j += 1
if j < n:
	print(j + 1)
else:
	print(n)


import sys

def main():
	fin = sys.stdin
	fout = sys.stdout
	n = int(fin.readline())
	s = list(fin.readline())
	i = 0
	while i < n and s[i] == '1':
		i += 1
	print(min(i + 1, n))
main()


n = int(input())
s = input()
ka = 0
for i in range(n):
	if s[i] == '1':
		ka = ka + 1
	else:
		ka = ka + 1
		break
print(ka)


def solve(a) -> int:
	cur = 1
	ret = 0
	for x in a:
		ret += 1
		cur += x
		if cur < 2:
			break
		cur //= 2
	return ret
input()
print(solve(list(map(int, input()))))


alph = 'abcdefghijklmnopqrstuvwxyz'
n = int(input())
s = str(input())
E = 0
d = []
for i in range(n):
	d.append(int(s[i]))
d.append(0)
d[0] += 1
for i in range(n):
	if d[i] > 1:
		d[i] = 0
		d[i + 1] += 1
		E += 1
	else:
		E += 1
		break
print(E)


n = int(input())
x = input()
c = 0
i = 0
while True:
	if x[i] == '0' or i == n - 1:
		c += 1
		break
	else:
		c += 1
	i += 1
print(c)


n = int(input())
s = input()
have = False
for i in range(0, n):
	if s[i] == '0':
		print(i + 1)
		have = True
	if have == True:
		break
if have == False:
	print(n)


n = int(input())
s = input()
if '0' not in s:
	ans = n
else:
	ans = s.index('0') + 1
print(ans)


def dectobin(n):
	r = ''
	if n == 0:
		return '0'
	while n > 0:
		r = str(n % 2) + r
		n = n // 2
	return r

def bintodec(n):
	r = 0
	i = 0
	while n > 0:
		r += n % 10 * 2 ** i
		n = n // 10
		i += 1
	return r
n = int(input())
s = input()
x = bintodec(int(s[::-1]))
y = dectobin(x + 1)
c = str(y)
c = c[::-1]
c = c + max(0, n - len(c)) * '0'
cnt = 0
for i in range(n):
	if s[i] != c[i]:
		cnt += 1
print(cnt)


t = int(input())
s = input()
l = int(s[::-1], 2) + 1
h = bin(l)[::-1]
w = h[:-2]
p = 0
q = len(w)
for k in range(t):
	if k <= q - 1:
		if w[k] != s[k]:
			p += 1
		else:
			pass
if k < t - 1:
	print(p + t - q)
else:
	print(p)


def inc_arg(s):
	count = 0
	s = list(s)
	for i in range(len(s)):
		if s[i] == '1':
			s[i] = '0'
			count += 1
		else:
			s[i] = '1'
			count += 1
			break
	return count
n = int(input())
print(inc_arg(input()))


n = int(input())
s = input()
x = 0
for i in s:
	if i == '1':
		x += 1
	elif i == '0':
		x += 1
		print(x)
		exit()
print(x)


n = input()
s = input()
add = 1
change = 0
for x in s:
	if x == '0' and add == 1:
		change = change + 1
		add = 0
	elif x == '1' and add == 1:
		change = change + 1
print(change)


n = int(input())
bits = input()
counter = 1
i = 0
while i < n - 1 and bits[i] == '1':
	counter += 1
	i += 1
print(counter)


n = input()
f = input()
m = 1
d = [int(x) for x in f]
d[0] += 1
for x in range(1, len(d)):
	if d[x - 1] > 1:
		d[x] += 1
		d[x - 1] = 0
		m += 1
print(m)


import math
n = int(input())

def replace(x):
	length = len(x)
	new = []
	for i in range(length):
		new.append(int(x[length - i - 1]))
	return new
d = list(input())
old_num_bin = replace(d)
old_num_value = 0
for i in range(n):
	old_num_value += int(d[i]) * pow(2, i)
new_num_value = old_num_value + 1
new_num_bin = list(bin(new_num_value)[2:])
if len(new_num_bin) < n:
	append_index = n - len(new_num_bin)
	for i in range(append_index):
		new_num_bin.insert(0, 0)
elif len(new_num_bin) > n:
	append_index = len(new_num_bin) - n
	new_num_bin = list(new_num_bin[append_index:])
k = 0
for i in range(n):
	if int(old_num_bin[i]) != int(new_num_bin[i]):
		k += 1
print(k)


n = int(input())
ori = input()
s = ori[::-1]
num = int(s, 2)
num += 1
bina = bin(num).replace('0b', '')
l = len(bina)
bina = bina[::-1]
if l < n:
	bina = bina + '0' * (n - l)
elif l > n:
	bina = bina[0:n]
c = 0
for i in range(n):
	if ori[i] != bina[i]:
		c += 1
print(c)


N = int(input())
S = input().split('0')
print(min(N, 1 + len(S[0])))


n = int(input())
bits = input()
x = int(bits[::-1], 2)
x += 1
if x == 2 ** n:
	x = 0
t = bin(x)[2:]
bits2 = ('0' * (n - len(t)) + t)[::-1]
cnt = 0
for i in range(n):
	if bits[i] != bits2[i]:
		cnt += 1
print(cnt)


n = int(input())
string = input()
a = 1
for x in range(n):
	if string[0] == '1':
		string = string.replace('1', '', 1)
		a += 1
	else:
		break
if a == n + 1:
	a = n
print(a)


n = int(input())
ar = input()
ind = 0
s = 0
for i in ar:
	if i == '1' and ind == 0:
		s += 1
	else:
		ind = 1
if s < len(ar):
	print(s + 1)
else:
	print(len(ar))


n = int(input())
s1 = input()
print((s1[0:-1] + '0').index('0') + 1)


n = input()
s = input()
x = s.find('0') + 1
if x:
	print(x)
else:
	print(len(s))


__author__ = 'hamed1soleimani'
n = int(input())
data = input()
i = data.find('0')
if i >= 0:
	print(i + 1)
else:
	print(n)


n = int(input())
a = input()
if '0' not in a:
	print(n)
else:
	print(a.index('0') + 1)


(n, box) = (int(input()), input())
ans = 1
if box[0] == '0':
	pass
else:
	for bit in box:
		if bit == '1':
			ans += 1
		else:
			break
print(min(ans, n))


x = int(input())
a = input()
mim = 0
for i in range(x):
	mim = mim + 1
	if a[i] == '0':
		break
print(mim)


input()
print((input()[:-1] + '0').index('0') + 1)


n = int(input())
s = input()
s = list(s)
s.reverse()
g = ''
for i in s:
	g += i
number = int(g, 2)
hold = number + 1
if hold >= 2 ** n:
	hold = hold % 2 ** n
b = hold ^ number
count = bin(b).count('1')
print(count)


n = int(input())
s = input()
s = list(map(int, s))
if 0 not in s:
	print(n)
elif 1 not in s or s[0] == 0:
	print(1)
else:
	count = 1
	for i in range(n - 1):
		if s[i] == 1 and s[i + 1] == 1:
			count += 1
		else:
			break
	print(count + 1)


n = int(input())
cell = input()
ans = 1
i = 0
if cell[i] == '1':
	while i < n - 1 and cell[i + 1] == '1':
		ans += 1
		i += 1
	if i < n - 1:
		ans += 1
print(ans)


n = int(input())
s = str(input())
r = 0
c = 1
for i in range(n):
	r += c
	c = (c + int(s[i])) // 2
print(r)


n = int(input())
s = input()
s_r = s[::-1]
s_b = int(s_r, 2)
s_inc = s_b + 1
f = '{0:0' + str(n) + 'b}'
s_inc_b = f.format(s_inc)
s_and = s_b ^ s_inc
s_inc_r = bin(s_and)[::-1][0:n]
print(s_inc_r.count('1'))


n = int(input())
a = list(map(int, list(input().strip())))
cnt = 0
now = 1
for i in range(n):
	if now:
		cnt += 1
		now = a[i] % 2
		a[i] += 1
		a[i] %= 2
print(cnt)


n = int(input())
s = input()
ans = 1
for i in s:
	if i == '1':
		ans += 1
	else:
		break
print(min(n, ans))


from sys import stdin

def func():
	n = stdin.readline()
	s = stdin.readline().strip()
	ind = s.find('0')
	digits_changed = 0
	if ind == -1:
		digits_changed = len(s)
	else:
		digits_changed = ind + 1
	print('{0}\n'.format(digits_changed))
func()


n = int(input())
a = [int(i) for i in input()]
r = 0
for i in a:
	if i == 0:
		break
	r += 1
print([r + 1, n][r == n])


n = int(input())
t = int(input()[::-1], 2)
p = t + 1
print(n if p == 1 << n else bin(t ^ p).count('1'))


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

def solve():
	n = int(input())
	s = input()
	x = int(s[::-1], 2)
	y = (x + 1) % (1 << n)
	print(bin(x ^ y).count('1'))
solve()


n = int(input())
old = input()
old = old[::-1]
m = int(old, 2)
m += 1
m = bin(m)
m = m[2:]
for x in range(500):
	m = '0' + m
m = m[-n:]
cnt = 0
for x in range(n):
	if old[x] != m[x]:
		cnt += 1
print(cnt)


def binary_to_decimal(s):
	n = 0
	for i in range(len(s)):
		n += int(s[i]) * 2 ** i
	return n

def decimal_to_binary(n):
	output_str = ''
	i = 0
	while 2 ** i <= n:
		i += 1
	i -= 1
	while i >= 0:
		if 2 ** i <= n:
			n -= 2 ** i
			output_str = '1' + output_str
		else:
			output_str = '0' + output_str
		i -= 1
	return output_str

def main_function():
	input()
	s = input()
	n = binary_to_decimal(s)
	new_n = n + 1
	new_binary_n = decimal_to_binary(new_n)
	count = 0
	for i in range(min(len(s), len(new_binary_n))):
		if s[i] != new_binary_n[i]:
			count += 1
	return count
print(main_function())


n = int(input())
m = int(input()[::-1], 2)
l = m + 1 & (1 << n) - 1
res = 0
for i in range(n):
	if m & 1 != l & 1:
		res += 1
	l >>= 1
	m >>= 1
print(res)


def main():
	n_bits = int(input())
	bits = input()
	try:
		print(bits.index('0') + 1)
	except ValueError:
		print(n_bits)
main()


n = int(input())
a = input()
for i in range(n):
	if a[i] == '0':
		break
print(min(n, i + 1))


n = int(input())
qb = [int(x) for x in input()]
qa = qb[:]
ans = 0
qa[0] += 1
for i in range(n):
	if qa[i] != qb[i]:
		ans += 1
		if qa[i] == 2:
			qa[i] = 0
			if i < n - 1:
				qa[i + 1] += 1
print(ans)


import sys
n = int(input())
s = input()
ls = 0
for i in range(n):
	if s[i] == '1':
		ls = i + 1
	else:
		break
print(min(ls + 1, n))


import sys
size = int(input())
string = str(input())
max = 0
counter = 0
for i in range(0, size):
	if string[i] == '1':
		counter += 1
	else:
		break
print(min(size, counter + 1))


def to_dec(bina):
	res = 0
	b = 2 ** len(bina)
	for i in range(len(bina)):
		b = b // 2
		if bina[i] == 1:
			res = res + b
	return res

def to_bin(d):
	res = []
	while d > 0:
		res.insert(0, d % 2)
		d = d // 2
	return ''.join(map(str, res))[::-1]
n = int(input())
b = input()
d = to_dec(list(map(int, b[::-1]))) + 1
b1 = to_bin(d)
if len(b1) < n:
	b1 = b1 + '0' * (n - len(b1))
res = 0
for i in range(n - 1, -1, -1):
	if b[i] != b1[i]:
		res += 1
print(res)


import re

def main():
	n = int(input())
	num = input()
	l = len(re.match('^1*', num).group(0))
	print(l + 1 if l < n else n)
main()


n = input()
s = input()
result = 0
for c in s:
	if c == '1':
		result += 1
	else:
		result += 1
		break
print(result)


n = int(input())
s = input()
a = 0
for i in range(n):
	a += 2 ** i * int(s[i])
a += 1
s2 = list(str(bin(a)))[2:]
s2.reverse()
while len(s2) < len(s):
	s2.append('0')
answ = 0
for i in range(n):
	if s[i] != s2[i]:
		answ += 1
print(answ)


n = int(input())
bx = input()
bxr = bx[::-1]
dx = int(bxr, 2)
dy = dx + 1
byr = bin(dy)[2:]
by = '{0:0<{1}}'.format(byr[::-1], n)
r = 0
for i in range(n):
	if bx[i] != by[i]:
		r += 1
print(r)


(n, t) = (input(), input())
i = t.find('0') + 1
print(i if i else n)


_1_ = int(input())
_2_ = input()
_3_ = 0
for _ in range(_1_):
	_3_ += 1
	if _2_[_] == '0':
		break
print(_3_)


n = int(input())
l = list(input())
li = [int(i) for i in l]
if 0 in li:
	print(li.index(0) + 1)
else:
	print(n)


import sys
cells = int(input())
cont = 0
for i in range(cells):
	x = sys.stdin.read(1)
	if x == '1':
		cont += 1
	else:
		cont += 1
		break
print(cont)


def bit_diff(n, k, ml):
	a = []
	b = []
	while n > 0:
		a.append(n % 2)
		n //= 2
	while k > 0:
		b.append(k % 2)
		k //= 2
	while len(b) < ml:
		b.append(0)
	while len(a) < ml:
		a.append(0)
	ans = 0
	for i in range(ml):
		ans += a[i] != b[i]
	return ans
n = int(input())
val = input()[::-1]
kl = int(val, 2)
print(abs(bit_diff(kl, kl + 1, n)))


n = int(input())
a = list(input())
i = 0
while a[i] == '1' and i + 1 < n:
	i += 1
print(i + 1)


n = int(input())
s = input()
t = 1
f = False
for i in s:
	if i == '0':
		f = True
		break
	else:
		t += 1
print(t - 1 if f == False else t)


n = int(input())
daf = list(input())
c = 1
for i in daf:
	if i == '1':
		c += 1
	else:
		break
print(min(n, c))


n = int(input())
d = n - len(input().lstrip('1'))
print(n if d == n else d + 1)


n = int(input()) + 1
r = int(input()[::-1], 2)
b = int('{:0{}b}'.format(r + 1, n)[1:], 2)
print(bin(r ^ b).count('1'))


n = int(input())
s = input() + '0'
t = 0
while s[t] == '1' and t != n:
	t += 1
if t < n:
	t += 1
print(t)


n = input()
x = input()
ret = 0
for a in x:
	ret += 1
	if a == '0':
		break
print(ret)


def solve():
	n = int(input())
	ans = 0
	k = input()
	p = 1
	if k[0] == '0':
		ans += 1
		print(ans)
	else:
		for i in range(n):
			if p == 0:
				break
			elif k[i] == '0':
				k = k[:i] + '1' + k[i + 1:]
				ans += 1
				p = 0
			else:
				k = k[:i] + '0' + k[i + 1:]
				ans += 1
		print(ans)
solve()


n = int(input())
s = input()
changes = 1
for c in s[:-1]:
	if c == '1':
		changes += 1
	else:
		break
print(changes)


SIZE = 10
matrix = [[0] * SIZE for i in range(SIZE)]
array = [0] * SIZE
n = input()
s = input()
ans = 0
for val in s:
	if val == '0':
		ans += 1
		break
	else:
		ans += 1
print(ans)


n = int(input())
s = input().strip()
a = int(s[::-1], 2)
res = str(bin(a ^ a + 1))[::-1]
res2 = res.split('b')[0]
if len(res2) > n:
	res2 = res2[:n]
print(sum([int(i) for i in res2]))


import re
from sys import stderr
from typing import Union, Generator, List, Tuple
import string

def main():
	n = int(input())
	bits = input()
	if '0' not in bits:
		res = len(bits)
	else:
		res = bits.index('0') + 1
	print(res)
main()


n = int(input())
a = input()
(c, d) = (0, 0)
for i in range(n):
	if a[i] == '1':
		c += 1
		d = 1
	elif a[i] == '0' and d == 1:
		c += 1
		d = 0
		break
	elif i == 0 and a[i] == '0' and (d == 0):
		c += 1
		break
print(c)


n = int(input())
s = input()
ans = 0
flag = 1
for ch in s:
	if ch == '0' and flag == 1:
		ans += 1
		flag = 0
	elif flag == 1:
		ans += 1
print(ans)


n = int(input())
source = str(input())
ref = n * [0]
carry = 1
for j in range(n):
	ref[j] = ord(source[j]) - 48
	if carry == 1:
		if ref[j] == 1:
			ref[j] = 0
		else:
			ref[j] = 1
			carry = 0
count = 0
for j in range(n):
	if ref[j] != ord(source[j]) - 48:
		count += 1
print(count)


bits = int(input())
num = input()
total = 0
for i in num:
	if i == '0':
		total += 1
		break
	else:
		total += 1
print(total)


input()
s = input()
i = 0
while i < len(s) and s[i] == '1':
	i += 1
print(min(i + 1, len(s)))


n = int(input())
k = input()
if int(k[0]) == 0:
	print(1)
else:
	s = 0
	for i in k:
		if int(i) == 1:
			s += 1
		else:
			break
	if s == n:
		print(n)
	else:
		print(s + 1)


n = input()
v = input()
count = 0
for c in v:
	count += 1
	if c != '1':
		break
print(count)


n = int(input())
a0 = input()
a = bin(int(a0[::-1], 2) + 1)[2:][::-1]
if len(a) < n:
	a += '0' * (n - len(a))
ans = 0
for i in range(n):
	ans += abs(int(a0[i]) - int(a[i]))
print(ans)


n = int(input())
s = input()
res = 0
for i in s:
	res += 1
	if i == '0':
		break
print(res)


n = int(input())
b = input()
d = int(b[::-1], 2) + 1
b1 = bin(d)[2:][::-1]
if len(b1) < n:
	b1 = b1 + '0' * (n - len(b1))
res = 0
for i in range(n - 1, -1, -1):
	if b[i] != b1[i]:
		res += 1
print(res)


n = int(input())
a = str(input())
(c, i, flag) = (0, 0, True)
while flag and i < n:
	if a[i] == '0':
		c += 1
		flag = False
	else:
		c += 1
		i += 1
print(c)


input()
s = input()
k = 0
for c in s:
	if c == '0':
		break
	k += 1
if k < len(s):
	k += 1
print(k)


import sys
import math
import bisect
import itertools
import random

def main():
	n = int(input())
	A = list((int(a) for a in input()[::-1]))
	val = 0
	for a in A:
		val = val * 2 + a
	val = val ^ (val + 1) % 2 ** n
	cnt = 0
	while val:
		cnt += val % 2
		val //= 2
	print(cnt)
main()


import sys
n = int(sys.stdin.readline())
instr = sys.stdin.readline()
carry = 1
result = 0
i = 0
while carry == 1:
	if instr[i] == '1':
		carry = 1
		result += 1
	elif instr[i] == '0' and carry == 1:
		carry = 0
		result += 1
	elif instr[i] == '1' and carry == 1:
		result += 1
	if i < n:
		i += 1
	else:
		break
print(result)


n = int(input())
s = list(input())
if '0' in s:
	print(s.index('0') + 1)
else:
	print(n)


numBits = int(input())
myStuff = list(map(int, list(input())))
add1 = True
numDiff = 0
for i in range(numBits):
	if add1:
		numDiff += 1
		myStuff[i] = myStuff[i] + 1 % 2
		if myStuff[i] == 1:
			add1 = False
print(numDiff)


n = int(input())
cell = input()
count1 = 0
for bit in cell:
	if bit == '1':
		count1 += 1
	else:
		break
if count1 < n:
	count1 += 1
print(count1)


n = int(input())
s = input()
ans = 0
i = 0
while i < n and s[i] == '1':
	i += 1
	ans += 1
print(max(1, min(ans + 1, n)))


n = int(input())
s = input()
k = 1
i = 0
while k and i < n:
	if s[i] != '1':
		k = 0
	i += 1
print(i)


n = int(input())
strnum = input()
count = 0
flag = 0
for x in strnum:
	if x == '1':
		count += 1
		continue
	else:
		flag = 1
		break
if flag:
	print(str(count + 1))
else:
	print(str(n))


input()
Number = input()
RevNumber = ''.join(reversed(Number))
RevNumber = bin(int(RevNumber, 2) + 1)[2:]
RevNumber = ''.join(reversed(RevNumber))
NotSame = 0
for i in range(min(len(RevNumber), len(Number))):
	if RevNumber[i] != Number[i]:
		NotSame += 1
print(NotSame)


n = int(input())
S = input()
k = 0
for i in range(n):
	if S[i] == '1':
		k = k + 1
	else:
		k = k + 1
		break
print(k)


n = int(input())
linha = input()
ans = 0
for e in linha:
	ans += 1
	if e == '0':
		break
print(ans)


w = int(input())
x = int(input()[::-1], 2)
y = (x + 1) % 2 ** w
print(bin(y ^ x).count('1'))


n = int(input())
a = list(input())
b = a[:]
x = 0
for i in range(n):
	if a[i] == '1' and x == 0:
		a[i] = '0'
		x = 1
	elif a[i] == '0':
		a[i] = '1'
		break
	elif a[i] == '1' and x == 1:
		a[i] = '0'
x = 0
for i in range(n):
	if a[i] != b[i]:
		x += 1
print(x)


n = int(input())
bit = input()
digits = []
digits2 = []
count = 1
for letter in bit:
	digits.append(int(letter))
	digits2.append(int(letter))
digits.append(0)
digits[0] += 1
while 2 in digits:
	x = digits.index(2)
	digits[x] = 0
	digits[x + 1] += 1
diff = 0
for i in range(n):
	if digits[i] == digits2[i]:
		pass
	else:
		diff += 1
print(diff)


n = int(input())
x = input()
s = '0b' + x[::-1]
s = bin(int(s, 2) + 1)[2:]
if len(s) > n:
	s = s[1:]
elif len(s) < n:
	d = n - len(s)
	s = '0' * d + s
s = s[::-1]
c = 0
for i in range(n):
	if s[i] != x[i]:
		c += 1
print(c)


n = int(input())
l = list(input())
m = []
d = []
for i in range(n):
	if i == 0 or d[-1] == 2:
		r = int(l[i]) + 1
		d.append(r)
		if r == 2:
			m.append('0')
		else:
			m.append(str(r))
	else:
		m.append(l[i])
		d.append(int(l[i]))
c = 0
for i in range(n):
	if l[i] != m[i]:
		c += 1
print(c)


input()
number = input()
i = 0
while i < len(number) and number[i] == '1':
	i += 1
if i + 1 > len(number):
	i = len(number) - 1
print(i + 1)


n = int(input())
digits = list(input())
addition = 1
res = 0
for i in range(n):
	sum_ = int(digits[i]) + addition
	if sum_ == 2:
		sum_ = 0
		addition = 1
	else:
		addition = 0
	if sum_ != int(digits[i]):
		res += 1
print(res)


n = int(input())
s = input()
cnt = 1
if s[0] == '0' or n == 1:
	print(1)
else:
	for i in range(1, n):
		if s[i] == '1':
			cnt += 1
		elif s[i] == '0':
			print(cnt + 1)
			break
		if i == n - 1:
			print(cnt)


n = int(input())
m = int(input()[::-1], 2)
mask = (1 << n) - 1
m = m ^ m + 1 & mask
rt = 0
while m:
	rt += m % 2
	m //= 2
print(rt)


n = input()
s = input()
i = 1
if n == '1':
	print(1)
else:
	while s[i - 1] == '1':
		i += 1
		if i >= len(s):
			break
	print(i)


n = int(input())
initial = input()[::-1]
final = ('{0:0%db}' % n).format(int(initial, 2) + 1)[-n:]
print(sum(list(map(lambda x: 1 if x[0] != x[1] else 0, zip(final, initial)))))


n = int(input())
a = list(input())
sum = 0
for i in range(n):
	if a[i] == '1':
		sum += 1
	else:
		sum += 1
		break
print(sum)


n = int(input())
lis = list(input())
if lis[0] == '0':
	print(1)
elif '0' not in lis:
	print(n)
else:
	print(lis.index('0') + 1)


a = input()
b = list(input())
b.append('0')
c = b.index('0')
if c + 1 == len(b):
	print(c)
else:
	print(c + 1)


import sys

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

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

def input():
	return sys.stdin.readline().strip('\n')
n = int(input())
s = input()
c = 0
i = 0
while i < n and s[i] == '1':
	c += 1
	i += 1
if i == n:
	print(c)
else:
	print(c + 1)