You are given two binary strings $a$ and $b$ of the same length. You can perform the following two operations on the string $a$:

  Swap any two bits at indices $i$ and $j$ respectively ($1 \le i, j \le n$), the cost of this operation is $|i - j|$, that is, the absolute difference between $i$ and $j$.  Select any arbitrary index $i$ ($1 \le i \le n$) and flip (change $0$ to $1$ or $1$ to $0$) the bit at this index. The cost of this operation is $1$. 

Find the minimum cost to make the string $a$ equal to $b$. It is not allowed to modify string $b$.


-----Input-----

The first line contains a single integer $n$ ($1 \le n \le 10^6$) — the length of the strings $a$ and $b$.

The second and third lines contain strings $a$ and $b$ respectively.

Both strings $a$ and $b$ have length $n$ and contain only '0' and '1'.


-----Output-----

Output the minimum cost to make the string $a$ equal to $b$.


-----Examples-----
Input
3
100
001

Output
2

Input
4
0101
0011

Output
1



-----Note-----

In the first example, one of the optimal solutions is to flip index $1$ and index $3$, the string $a$ changes in the following way: "100" $\to$ "000" $\to$ "001". The cost is $1 + 1 = 2$.

The other optimal solution is to swap bits and indices $1$ and $3$, the string $a$ changes then "100" $\to$ "001", the cost is also $|1 - 3| = 2$.

In the second example, the optimal solution is to swap bits at indices $2$ and $3$, the string $a$ changes as "0101" $\to$ "0011". The cost is $|2 - 3| = 1$.

Difficulty: EASY
Tags: String algorithms

Dynamic programming

Greedy algorithms
Skill types: Dynamic programming

Greedy algorithms
Expected Time Complexity: O(N)

Starter code:

Solutions:
n = int(input())
l = list(input())
d = list(input())
c = 0
for i in range(n - 1):
	if l[i] != d[i]:
		if l[i] == d[i + 1] and d[i] == l[i + 1]:
			l[i] = d[i]
			l[i + 1] = d[i + 1]
			c = c + 1
		else:
			c = c + 1
			l[i] = d[i]
if d[-1] != l[-1]:
	c = c + 1
print(c)


tam = int(input())
a = input()
b = input()
cost = 0
skip = False
for i in range(tam):
	if a[i] == b[i] or skip:
		skip = False
		continue
	if i < tam - 1 and a[i] != b[i] and (a[i + 1] == b[i]) and (b[i + 1] == a[i]):
		cost += 1
		skip = True
		continue
	cost += 1
print(cost)


n = int(input())
a = list((i for i in input()))
b = list((i for i in input()))
c = list(a)
d = list(b)
do_nothing = 0
a.append('2')
b.append('2')
cn = 0
for i in range(n):
	if a[i] == b[i]:
		do_nothing = 1
	elif a[i] == b[i + 1] and a[i + 1] == b[i]:
		cn += 1
		(a[i], a[i + 1]) = (a[i + 1], a[i])
	elif a[i] != b[i]:
		cn += 1
		a[i] = b[i]
print(cn)


k = int(input())
s1 = input()
b = input()
a = []
for elem in s1:
	a.append(elem)
i = 0
ans = 0
while i < len(a) - 1:
	f = a[i] + a[i + 1]
	g = b[i + 1] + b[i]
	if f == g and (f == '10' or f == '01'):
		(a[i], a[i + 1]) = (a[i + 1], a[i])
		i += 1
		ans += 1
	else:
		i += 1
for i in range(len(a)):
	if a[i] != b[i]:
		ans += 1
print(ans)


n = input()
fst = list(input())
snd = input()
c = 0
for i in range(len(fst)):
	if fst[i] != snd[i]:
		if i < len(fst) - 1 and fst[i] != fst[i + 1] and (snd[i] != snd[i + 1]):
			(fst[i], fst[i + 1]) = (fst[i + 1], fst[i])
		else:
			fst[i] = '1' if fst[i] == 0 else '0'
		c += 1
print(c)


n = int(input())
a = input()
b = input()
i = 0
t = 0
f = 0
while i < n:
	(m, k) = (a[i], b[i])
	if i == 0:
		if m != k:
			t = 1
	elif i >= 1:
		if m != k:
			t += 1
			if m == b[i - 1] and k == a[i - 1] and (f == 0):
				t = t - 1
				f = 1
			else:
				f = 0
	i += 1
print(t)


n = int(input())
a = list(input())
b = list(input())
c = 0
for i in range(n - 1):
	if a[i] == b[i + 1] and a[i + 1] == b[i] and (a[i] != a[i + 1]):
		c += 1
		(a[i], a[i + 1]) = (a[i + 1], a[i])
for i in range(n):
	if a[i] != b[i]:
		c += 1
print(c)


n = int(input())
a = input()
b = input()
a0 = list()
a1 = list()
ans = 0
f = 0
c = 0
for i in range(n):
	if f == 0:
		if a[i] == '0' and b[i] == '1':
			ans += 1
			f = 1
			c = 1
		elif a[i] == '1' and b[i] == '0':
			ans += 1
			f = 1
			c = 0
	elif a[i] == '0' and b[i] == '1' and (c == 0):
		f = 0
	elif a[i] == '1' and b[i] == '0' and (c == 1):
		f = 0
	elif a[i] == '0' and b[i] == '1':
		ans += 1
		c = 1
	elif a[i] == '1' and b[i] == '0':
		ans += 1
		c = 0
	elif a[i] == b[i]:
		f = 0
print(ans)


(n, a, b) = (int(input()), input() + '0', input() + '0')
cnt = 0
i = 0
while i < n:
	if a[i] != b[i]:
		i += 2 if a[i + 1] != b[i + 1] and a[i] == b[i + 1] else 1
		cnt += 1
	else:
		i += 1
print(cnt + (a[-1] != b[-1]))


R = lambda : map(int, input().split())
n = int(input())
(s1, s2) = (input(), input())
i = 0
res = 0
while i < n:
	if s1[i] != s2[i]:
		if i < n - 1 and s1[i] != s1[i + 1] and (s1[i + 1] != s2[i + 1]):
			i += 1
		res += 1
	i += 1
print(res)


input()
last_c1 = '1'
last_nav = True
res = 0
for (c1, c2) in zip(input(), input()):
	cur_av = c1 != c2 and (last_nav or c1 == last_c1)
	if cur_av:
		last_c1 = c1
		res += 1
	last_nav = not cur_av
print(res)


a = int(input())
b = input()
c = input()
k = 0
l = 0
while True:
	if k >= a:
		break
	elif k == a - 1:
		if b[k] == c[k]:
			k += 1
		else:
			k += 1
			l += 1
	elif b[k] == c[k]:
		k += 1
	elif b[k] == c[k + 1] and b[k + 1] == c[k]:
		l += 1
		k += 2
	else:
		k += 1
		l += 1
print(l)


import sys
input = sys.stdin.readline
from math import log2, log, ceil

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().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
n = int(input())
a = input().strip()
b = input().strip()
i = 0
ans = 0
while i < n:
	if a[i] == b[i]:
		i += 1
	else:
		if i == n - 1:
			ans += 1
			break
		if a[i:i + 2] == b[i:i + 2][::-1]:
			i += 2
			ans += 1
		else:
			i += 1
			ans += 1
print(ans)


n = int(input())
s1 = list(input())
s2 = list(input())
i = 0
ans = 0
while i < n - 1:
	if s1[i] != s2[i] and s1[i + 1] != s2[i + 1] and (s1[i] == s2[i + 1]):
		s2[i] = s1[i]
		s2[i + 1] = s1[i + 1]
		ans += 1
		i += 2
	else:
		i += 1
i = 0
while i < n:
	if s1[i] != s2[i]:
		ans += 1
	i += 1
print(ans)


import math
n = map(int, input())
a = input()
b = input()
count = 0
cur_pos = 0
(pos_i, pos_j) = (-10, -10)
for (i, j) in zip(a, b):
	if i == j:
		pass
	elif i == '1' and j == '0':
		if pos_j == cur_pos - 1:
			pass
		else:
			count += 1
			pos_i = cur_pos
	elif pos_i == cur_pos - 1:
		pass
	else:
		count += 1
		pos_j = cur_pos
	cur_pos += 1
print(count)


n = int(input())
a = list(input())
b = list(input())
ans = 0
for i in range(n - 1):
	if a[i] != a[i + 1] and b[i] != b[i + 1] and (a[i] != b[i]):
		ans += 1
		a[i + 1] = b[i + 1]
		continue
	if a[i] != b[i]:
		ans += 1
if a[-1] != b[-1]:
	ans += 1
print(ans)


a = int(input())
s1 = input()
s2 = input()
one = []
zero = []
count = 0
for i in range(len(s1)):
	if s1[i] == '1' and s2[i] == '0':
		one.append(i)
		if len(zero) != 0:
			if abs(one[-1] - zero[-1]) < 2:
				count = count + 1
				one[-1] = -1
				zero[-1] = -1
	elif s1[i] == '0' and s2[i] == '1':
		zero.append(i)
		if len(one) != 0:
			if abs(one[-1] - zero[-1]) < 2:
				count = count + 1
				one[-1] = -1
				zero[-1] = -1
print(count + (len(one) + len(zero)) - one.count(-1) - zero.count(-1))


from sys import stdin

def myfunction(a, b, n):
	moves = 0
	i = 0
	while i < n:
		if a[i] != b[i]:
			try:
				if a[i] == b[i + 1] and a[i + 1] == b[i]:
					moves += 1
					i += 2
					continue
				else:
					moves += 1
					i += 1
					continue
			except:
				moves += 1
				i += 1
				continue
		i += 1
	return moves
n = int(stdin.readline().strip())
a = list(stdin.readline().strip())
b = list(stdin.readline().strip())
print(myfunction(a, b, n))


m = int(input())
a = input()
b = input()
l_a = []
l_b = []
for k in range(m):
	l_a += a[k]
	l_b += b[k]

def main():
	s = 0
	for i in range(m):
		if l_a[i] != l_b[i]:
			if i == m - 1:
				s += 1
			elif l_a[i] != l_a[i + 1] and l_a[i + 1] != l_b[i + 1]:
				s += 1
				(l_a[i], l_a[i + 1]) = (l_a[i + 1], l_a[i])
			else:
				s += 1
	return s
print(main())


import sys
f = sys.stdin
n = int(f.readline().rstrip('\r\n'))
s1 = list(f.readline().rstrip('\r\n'))
s2 = list(f.readline().rstrip('\r\n'))
s1.append('0')
s2.append('0')
c = 0
for i in range(n):
	if s1[i] != s2[i] and s1[i + 1] != s2[i + 1] and (s1[i] == s2[i + 1]) and (s1[i + 1] == s2[i]):
		(s1[i], s1[i + 1]) = (s1[i + 1], s1[i])
		c += 1
	elif s1[i] != s2[i]:
		if s2[i] == '0':
			s1[i] = '0'
		else:
			s1[i] = '1'
		c += 1
print(c)


def solve(a, b):
	(i, n) = (0, len(a))
	res = 0
	while i < n:
		if a[i] == b[i]:
			i += 1
			continue
		res += 1
		if i < n - 1 and a[i + 1] != b[i + 1] and (a[i] != a[i + 1]):
			i += 2
		else:
			i += 1
	return res
input()
a = input().strip()
b = input().strip()
print(solve(a, b))


import sys
import math
import collections

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

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

def get_string():
	return sys.stdin.readline().strip()
for t in range(1):
	n = int(input())
	a = list(input())
	b = list(input())
	cost = 0
	ans = []
	for i in range(n):
		if a[i] == b[i]:
			continue
		else:
			ans.append(i)
	count = 0
	i = 1
	maxim = len(ans)
	while i < maxim:
		if ans[i] - ans[i - 1] == 1 and a[ans[i]] != a[ans[i - 1]]:
			cost += 1
			count += 2
			i += 2
		else:
			i += 1
	cost += maxim - count
	print(cost)


_ = input()
a = input()
b = input()
i = 0
cost = 0
while i < len(a):
	if a[i] != b[i]:
		if i + 1 < len(a):
			if a[i] == b[i + 1] and a[i + 1] == b[i]:
				i += 1
			cost += 1
		else:
			cost += 1
	i += 1
print(cost)


from sys import stdin
n = int(input())
a = list(stdin.readline().rstrip())
b = list(stdin.readline().rstrip())
t = 0
for i in range(n - 1):
	if a[i] == b[i + 1] and b[i] == a[i + 1] and (a[i] != a[i + 1]):
		(a[i], a[i + 1]) = (a[i + 1], a[i])
		t += 1
	elif a[i] != b[i]:
		a[i] = b[i]
		t += 1
if a[-1] != b[-1]:
	a[-1] = b[-1]
	t += 1
print(t)


n = int(input())
x = input()
y = input()
(i, ans) = (0, 0)
while i < n:
	if x[i] == y[i]:
		i += 1
	else:
		if i < n - 1 and x[i] == y[i + 1] and (x[i + 1] == y[i]):
			i += 1
		ans += 1
		i += 1
print(ans)


input()
r = l = 0
for (x, y) in zip(input(), input()):
	l = y != x != l
	r += l
	l *= y
print(r)


n = int(input())
a = list(input())
b = list(input())
s = 0
c = 0
i = 0
while i < n - 1:
	if a[i] != b[i] and a[i + 1] != b[i + 1] and (a[i] != a[i + 1]):
		s += 1
		i += 2
	else:
		i += 1
for i in range(n):
	if a[i] != b[i]:
		c += 1
print(c - s)


n = int(input())
a = list(input())
b = list(input())
ans = 0
for i in range(n - 1):
	a1 = a[i]
	a2 = a[i + 1]
	if a1 == b[i]:
		continue
	if a2 == b[i] and a1 == b[i + 1]:
		ans += 1
		a[i + 1] = a1
		a[i] = a2
		if i == n - 1:
			break
	else:
		ans += 1
if a[n - 1] != b[n - 1]:
	ans += 1
print(ans)


n = int(input())
a = str(input())
b = str(input())
(t, i) = (0, 0)
while i < n:
	if a[i] != b[i]:
		t += 1
		try:
			if a[i + 1] != b[i + 1] and a[i] != a[i + 1]:
				i += 1
		except:
			break
	i += 1
print(t)


n = int(input())
a = [int(i) for i in input()]
b = [int(i) for i in input()]
i = 0
ans = 0
while i < len(a) - 1:
	if a[i] != a[i + 1] and b[i] == a[i + 1] and (b[i + 1] == a[i]):
		a[i] = 1 - a[i]
		a[i + 1] = 1 - a[i + 1]
		ans += 1
		i += 2
	else:
		i += 1
for i in range(len(a)):
	if a[i] != b[i]:
		ans += 1
print(ans)


n = int(input())
one = list(input())
two = list(input())
(ans, i) = (0, 0)
while i < n:
	if one[i] != two[i]:
		if i < n - 1 and one[i] == two[i + 1] and (one[i + 1] == two[i]):
			i += 1
		ans += 1
	i += 1
print(ans)


m = input()
a = input()
b = input()
d = [0] * int(m)
d[0] = 0 if a[0] == b[0] else 1
for i in range(1, int(m)):
	if a[i] == b[i]:
		d[i] = d[i - 1]
	elif a[i] != a[i - 1] and a[i - 1] != b[i - 1]:
		d[i] = d[i - 2] + 1
	else:
		d[i] = d[i - 1] + 1
print(d[-1])


n = int(input())
ini = input()
fin = input()
ini = list(ini)
fin = list(fin)
cost = 0
for i in range(n - 1):
	if ini[i] == fin[i + 1] and ini[i + 1] == fin[i] and (ini[i] != ini[i + 1]):
		cost += 1
		(ini[i], ini[i + 1]) = (ini[i + 1], ini[i])
for i in range(n):
	if ini[i] != fin[i]:
		cost += 1
print(cost)


n = int(input())
a = input()
b = input()
i = 0
cost = 0
while i < n:
	if a[i] == b[i]:
		i = i + 1
		continue
	if i + 1 < n and a[i + 1] == b[i] and (a[i] == b[i + 1]):
		cost = cost + 1
		i = i + 2
		continue
	if a[i] != b[i]:
		cost = cost + 1
	i = i + 1
print(cost)


I = input
(n, A, B, swaps) = (int(I()), list(I()), list(I()), 0)
for i in range(n - 1):
	if ''.join(A[i:i + 2] + B[i:i + 2]) in ('0110', '1001'):
		(A[i:i + 2], swaps) = (B[i:i + 2], swaps + 1)
print(swaps + sum((a != b for (a, b) in zip(A, B))))


import sys
import os
import collections
n = int(input())
a = input()
b = input()
s = 0
i = 0
while i < n - 1:
	if a[i] == '0' and b[i] == '1' and (a[i + 1] == '1') and (b[i + 1] == '0'):
		s += 1
		i += 1
	elif a[i] == '1' and b[i] == '0' and (a[i + 1] == '0') and (b[i + 1] == '1'):
		s += 1
		i += 1
	i += 1
c = 0
for i in range(0, n):
	if a[i] != b[i]:
		c += 1
print(c - s)


x = int(input())
(*li1,) = input()
(*li2,) = input()
cnt = 0
i = 0
while i < x:
	if li2[i] != li1[i]:
		if i < x - 1 and (li1[i + 1] != li2[i + 1] and li1[i + 1] != li1[i]):
			cnt += 1
			i += 1
		else:
			cnt += 1
	i += 1
print(cnt)


def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = 0
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = 1
			break
	return ans

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = mpos(sum_so_far, current_sum)
	return sum_so_far

def pref(li):
	pref_sum = [0]
	for i in li:
		pref_sum.append(pref_sum[-1] + i)
	return pref_sum
from math import *
mod = 1000000007
for _ in range(1):
	n = int(input())
	a = list(input())
	b = list(input())
	a += 'x'
	b += 'x'
	ans = 0
	i = 0
	while i < n:
		if a[i] != b[i]:
			if a[i + 1] != b[i + 1] and a[i] != a[i + 1]:
				ans += 1
				i += 2
			else:
				ans += 1
				i += 1
		else:
			i += 1
	print(ans)


n = int(input())
a = input()
b = input()
cnt = 0
for i in range(n):
	if a[i] != b[i]:
		cnt += 1
i = 1
while i < n:
	if a[i] != b[i] and a[i - 1] != b[i - 1] and (a[i] != a[i - 1]):
		cnt -= 1
		i += 1
	i += 1
print(cnt)


import atexit
import io
import sys
R = lambda : map(int, input().split())
n = int(input())
lst1 = input()
lst2 = input()
(i, ans) = (0, 0)
while i < n:
	if lst1[i] != lst2[i]:
		if i < n - 1 and lst1[i] == lst2[i + 1] and (lst1[i + 1] == lst2[i]):
			i += 1
		ans += 1
	i += 1
print(ans)


n = int(input())
a = list(map(str, input()))
b = list(map(str, input()))
ans = 0
for i in range(n - 1):
	if a[i] != a[i + 1] and a[i] == b[i + 1] and (a[i + 1] == b[i]):
		(a[i], a[i + 1]) = (a[i + 1], a[i])
		ans += 1
for i in range(n):
	if a[i] != b[i]:
		ans += 1
print(ans)


n = int(input())
word1 = list(map(str, input()))
word2 = list(map(str, input()))
ans = 0
for i in range(n - 1):
	if word1[i] != word2[i]:
		if word1[i + 1] != word2[i + 1]:
			if word1[i] == '1' and word1[i + 1] == '0' and (word2[i] == '0') and (word2[i + 1] == '1'):
				word1[i] = '0'
				word1[i + 1] = '1'
				ans += 1
			elif word1[i] == '0' and word1[i + 1] == '1' and (word2[i] == '1') and (word2[i + 1] == '0'):
				word1[i] = '1'
				word1[i + 1] = '0'
				ans += 1
for i in range(n):
	if word1[i] != word2[i]:
		ans += 1
print(ans)


length = input()
a = input()
b = input()
cost = 0
prev = False
for i in range(0, int(length)):
	if a[i] != b[i]:
		if prev:
			if a[i] == a[i - 1]:
				cost += 1
			else:
				prev = False
		else:
			cost += 1
			prev = True
	else:
		prev = False
print(cost)


n = int(input())
string1 = input()
string2 = input()
i = 0
s = 0
while i < n - 1:
	if string1[i] == string2[i]:
		i += 1
	elif string1[i + 1] == string2[i + 1]:
		s += 1
		i += 1
	else:
		s += 1
		if string1[i] == string1[i + 1]:
			i += 1
		else:
			i += 2
if i == n:
	print(s)
elif string1[-1] == string2[-1]:
	print(s)
else:
	print(s + 1)


n = int(input())
a = list(input())
b = list(input())
count = 0
skip_next = False
for idx in range(n - 1):
	if skip_next:
		skip_next = False
		continue
	if a[idx] != b[idx] and a[idx] == b[idx + 1] and (a[idx + 1] == b[idx]):
		count += 1
		a[idx] = b[idx]
		a[idx + 1] = b[idx + 1]
		skip_next = True
for idx in range(n):
	if a[idx] != b[idx]:
		count += 1
print(count)


def main():
	n = int(input())
	a = list(input())
	b = list(input())
	moves = 0
	for i in range(n - 1):
		if a[i] == b[i + 1] and a[i + 1] == b[i] and (a[i] != b[i]) and (a[i + 1] != b[i + 1]):
			(a[i], a[i + 1]) = (a[i + 1], a[i])
			moves += 1
		elif a[i] != b[i]:
			a[i] = b[i]
			moves += 1
	if a[-1] != b[-1]:
		moves += 1
	print(moves)
main()


input()
(res, c) = (0, ' ')
for (a, b) in zip(input(), input()):
	if b != a != c:
		res += 1
		c = b
	else:
		c = ' '
print(res)


n = int(input()) + 1
a = '0' + input()
b = '0' + input()
dp = [0] * n
dp[0] = 0
k01 = -1
k10 = -1
for i in range(n):
	if a[i] == b[i]:
		dp[i] = dp[i - 1]
	elif a[i] == '0' and b[i] == '1':
		k01 = i
		if k10 == -1:
			dp[i] = 1 + dp[i - 1]
		else:
			dp[i] = min(1 + dp[i - 1], dp[k10 - 1] + i - k10)
	else:
		k10 = i
		if k01 == -1:
			dp[i] = 1 + dp[i - 1]
		else:
			dp[i] = min(1 + dp[i - 1], dp[k01 - 1] + i - k01)
print(dp[n - 1])


def main():
	n = int(input())
	(a, b) = (list(input()), input())
	ans = 0
	for i in range(n - 1):
		if a[i] != b[i]:
			if a[i] != a[i + 1] and a[i + 1] != b[i + 1]:
				(a[i], a[i + 1]) = (a[i + 1], a[i])
			else:
				a[i] = '1' if a[i] == '0' else '0'
			ans += 1
	if a[-1] != b[-1]:
		ans += 1
	print(ans)
main()


(n, c, i) = (int(input()), 0, 0)
a = list(input())
b = list(input())
while i < n - 1:
	if a[i] == b[i]:
		i += 1
		continue
	elif a[i] != a[i + 1] and a[i + 1] != b[i + 1]:
		a[i] = b[i]
		a[i + 1] = b[i + 1]
		c += 1
		i += 2
	else:
		i += 1
		c += 1
if a[n - 1] != b[n - 1]:
	print(c + 1)
else:
	print(c)


n = int(input())
(str1, str2) = (input(), input())
s1 = list(str1)
s2 = list(str2)
ans = 0
(i1, j1) = (-1, -1)
for i in range(0, n - 1):
	if s1[i] == s2[i]:
		continue
	elif s1[i + 1] == s2[i] and s1[i + 1] != s2[i + 1]:
		(s1[i], s1[i + 1]) = (s1[i + 1], s1[i])
		ans += 1
	elif s1[i - 1] == s2[i] and s1[i - 1] != s2[i - 1] and (i != 0):
		(s1[i], s1[i - 1]) = (s1[i - 1], s1[i])
		ans += 1
for i in range(0, n):
	if s1[i] != s2[i]:
		ans += 1
print(ans)


n = int(input())
a = list(input())
b = list(input())
c = 0
i = 0
while i < n:
	if a[i] != b[i]:
		if i < n - 1 and a[i + 1] == b[i] and (a[i] == b[i + 1]):
			i += 1
		c += 1
	i += 1
print(c)


n = int(input())
a = [int(x) for x in input()]
b = [int(x) for x in input()]
count = 0
for i in range(n):
	if a[i] == b[i]:
		continue
	elif i + 1 < n and a[i] != a[i + 1] and (b[i] != b[i + 1]):
		(a[i], a[i + 1]) = (a[i + 1], a[i])
		count += 1
	else:
		a[i] = b[i]
		count += 1
print(count)


n = int(input())
a = list(input())
b = list(input())
count = 0
for i in range(n - 1):
	if a[i] != b[i]:
		if b[i + 1] == a[i] and b[i] == a[i + 1]:
			(b[i + 1], b[i]) = (b[i], b[i + 1])
			count += 1
		else:
			count += 1
if a[n - 1] != b[n - 1]:
	count += 1
print(count)


n = int(input())
a = str(input())
b = str(input())
counter = 0
i = 0
while i < n:
	if a[i] == b[i]:
		i += 1
	elif i < n - 1 and a[i] == b[i + 1] and (not a[i + 1] == b[i + 1]):
		counter += 1
		i += 2
	else:
		counter += 1
		i += 1
print(counter)


from sys import stdin

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

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

def li():
	return list(mi())

def si():
	return stdin.readline()
n = ii()
a = si()
b = si()
x = i = 0
while i < n:
	if a[i] != b[i]:
		x += 1
		if i < n - 1 and a[i] == b[i + 1]:
			i += 1
	i += 1
print(x)


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

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

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

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

def main():
	n = int(input())
	cost = 0
	str_a = list(input().strip())
	str_b = list(input().strip())
	for i in range(len(str_a) - 1):
		if str_a[i] == str_b[i]:
			continue
		elif str_a[i] == str_b[i + 1] and str_b[i] == str_a[i + 1]:
			str_b[i] = str(1 - int(str_b[i]))
			str_b[i + 1] = str(1 - int(str_b[i + 1]))
			cost += 1
		else:
			str_b[i] = str(1 - int(str_b[i]))
			cost += 1
	if str_a[-1] != str_b[-1]:
		cost += 1
	print(cost)
main()


import os
import sys
import math
from io import BytesIO, IOBase
input = sys.stdin.readline

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

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

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

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

def dijkstra(start, distance, path, n):
	visited = [False for _ in range(n)]
	distance[start] = 0
	for i in range(n):
		v = -1
		for j in range(n):
			if not visited[v] and (v == -1 or distance[j] < distance[v]):
				v = j
		if distance[v] == math.inf:
			break
		visited[v] = True
		for edge in adj[v]:
			destination = edge[0]
			weight = edge[1]
			if distance[v] + weight < distance[destination]:
				distance[destination] = distance[v] + weight
				path[destination] = v

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

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

def ncr(n, r):
	return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def npr(n, r):
	return math.factorial(n) // math.factorial(n - r)

def seive(n):
	primes = [True] * (n + 1)
	ans = []
	for i in range(2, n):
		if not primes[i]:
			continue
		j = 2 * i
		while j <= n:
			primes[j] = False
			j += i
	for p in range(2, n + 1):
		if primes[p]:
			ans += [p]
	return ans

def factors(n):
	factors = []
	x = 1
	while x * x <= n:
		if n % x == 0:
			if n // x == x:
				factors.append(x)
			else:
				factors.append(x)
				factors.append(n // x)
		x += 1
	return factors

def main():
	try:
		n = inp()
		a = list(input())
		b = list(input())
		ans = 0
		for i in range(n - 1):
			if a[i] != b[i]:
				if a[i + 1] != b[i + 1] and a[i + 1] != a[i]:
					(a[i], a[i + 1]) = (a[i + 1], a[i])
				ans += 1
		if a[-1] != b[-1]:
			ans += 1
		print(ans)
	except Exception as e:
		print(e)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

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

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

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

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

class IOWrapper(IOBase):

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


def solve(n, a, b):
	ans = 0
	i = 0
	while i < n:
		if a[i] != b[i]:
			if i < n - 1 and a[i + 1] != b[i + 1] and (a[i + 1] != a[i]):
				ans += 1
				i += 2
			else:
				ans += 1
				i += 1
		else:
			i += 1
	return ans
n = int(input())
a = input()
b = input()
print(solve(n, a, b))


n = int(input())
s1 = [int(i) for i in input()]
s2 = [int(i) for i in input()]
cnt = 0
for i in range(n):
	if s1[i] != s2[i]:
		cnt += 1
i = 0
while i < n - 1:
	if (s1[i] == 1 and s2[i] == 0) and (s1[i + 1] == 0 and s2[i + 1] == 1):
		cnt -= 1
		i += 2
	elif (s1[i] == 0 and s2[i] == 1) and (s1[i + 1] == 1 and s2[i + 1] == 0):
		cnt -= 1
		i += 2
	else:
		i += 1
print(cnt)


import atexit
import io
import sys
inf = float('inf')
inf_neg = float('-inf')
range_5 = int(100000.0 + 1)
range_6 = int(1000000.0 + 1)
range_7 = int(10000000.0 + 1)
range_8 = int(100000000.0 + 1)
_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER

@atexit.register
def write():
	sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())

def main():
	n = int(input())
	a = list(input())
	b = list(input())
	ret = 0
	for i in range(n - 1):
		if a[i] == '0' and b[i] == '1' and (a[i + 1] == '1') and (b[i + 1] == '0'):
			(a[i], a[i + 1]) = (a[i + 1], a[i])
			ret += 1
		elif a[i] == '1' and b[i] == '0' and (a[i + 1] == '0') and (b[i + 1] == '1'):
			(a[i], a[i + 1]) = (a[i + 1], a[i])
			ret += 1
	for i in range(n):
		if a[i] != b[i]:
			ret += 1
	print(ret)
main()


from __future__ import division, print_function
from io import BytesIO, IOBase
import os, sys, math, heapq, copy
from collections import defaultdict, deque
from bisect import bisect_left, bisect_right
from functools import cmp_to_key
from itertools import permutations, combinations, combinations_with_replacement
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
mod = 1000000007

def get_int():
	return int(sys.stdin.readline().strip())

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

def get_float():
	return float(sys.stdin.readline().strip())

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

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

def get_floats():
	return map(float, sys.stdin.readline().strip().split())

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

def list_strs():
	return list(map(str, sys.stdin.readline().strip().split()))

def list_floats():
	return list(map(float, sys.stdin.readline().strip().split()))
n = get_int()
a = get_str()
b = get_str()
cost = 0
i = 0
while i < n:
	if a[i] == '0' and b[i] == '1':
		cost += 1
		if i + 1 < n and a[i + 1] == '1' and (b[i + 1] == '0'):
			i += 1
	elif a[i] == '1' and b[i] == '0':
		cost += 1
		if i + 1 < n and a[i + 1] == '0' and (b[i + 1] == '1'):
			i += 1
	i += 1
print(cost)


input()
c = p = 0
for (i, j) in zip(input(), input()):
	p = j != i != p
	c += p
	p *= j
print(c)


n = int(input())
a = input()
b = input()
cost = 0
i = 0
last_symbol = ''
while i < n:
	if last_symbol != a[i] != b[i]:
		cost += 1
		last_symbol = b[i]
	else:
		last_symbol = ''
	i += 1
print(cost)


length = int(input())
(a, b) = (list(input()), list(input()))
(ans, i) = (0, 0)
while i < length - 1:
	if a[i] != b[i] and a[i + 1] != b[i + 1] and (a[i] != a[i + 1]):
		ans += 1
		a[i] = b[i]
		a[i + 1] = b[i + 1]
		i += 2
	else:
		i += 1
print(ans + sum([1 for i in range(length) if a[i] != b[i]]))


def bin_edit_dist(a, b, n):
	ans = 0
	i = 0
	while i < n - 1:
		if a[i] == b[i]:
			i += 1
		elif a[i + 1] == b[i + 1]:
			ans += 1
			i += 2
		elif a[i] != a[i + 1]:
			ans += 1
			i += 2
		else:
			ans += 1
			i += 1
	if i == n - 1 and a[i] != b[i]:
		ans += 1
	return ans

def main():
	n = int(input())
	a = input()
	b = input()
	print(bin_edit_dist(a, b, n))
main()


n = int(input())
d1 = list(input())
d2 = list(input())
k = 0
for i in range(n - 1):
	if d1[i] != d2[i]:
		if d1[i] != d1[i + 1] and d1[i] == d2[i + 1] and (d1[i + 1] == d2[i]):
			(d1[i], d1[i + 1]) = (d1[i + 1], d1[i])
			k += 1
		else:
			k += 1
			d1[i] = d2[i]
if d1[n - 1] != d2[n - 1]:
	k += 1
print(k)


n = int(input())
num1 = list(input())
num2 = list(input())
cost = 0
for i in range(n - 1):
	if num1[i] == num1[i + 1]:
		continue
	elif num1[i] != num1[i + 1]:
		if num1[i] == num2[i]:
			continue
		elif num1[i + 1] != num2[i + 1]:
			(num1[i], num1[i + 1]) = (num1[i + 1], num1[i])
			cost = cost + 1
		else:
			continue
for i in range(n):
	if num1[i] != num2[i]:
		cost = cost + 1
print(cost)


input()
c = p = 0
for (x, y) in zip(input(), input()):
	if y != x != p:
		c += 1
		p = y
	else:
		p = 0
print(c)


import sys
import math
n = int(input())
a = input()
b = input()
count = 0
i = 0
while i < n:
	if a[i] != b[i]:
		if i + 1 < n and a[i + 1] != b[i + 1] and (a[i] != a[i + 1]):
			i += 1
		count += 1
	i += 1
print(count)


n = int(input())
a = [ch for ch in input()]
b = [ch for ch in input()]
res = 0
for i in range(n - 1):
	if a[i] != a[i + 1] and a[i] != b[i] and (a[i + 1] != b[i + 1]):
		res += 1
		(a[i], a[i + 1]) = (a[i + 1], a[i])
for i in range(n):
	res += a[i] != b[i]
print(res)


n = int(input())
a = input()
b = input()
res = 0
ind = 0
while ind < n:
	if a[ind] != b[ind]:
		res += 1
		if ind < n - 1 and a[ind + 1] != b[ind + 1] and (a[ind] != a[ind + 1]):
			ind += 1
	ind += 1
print(res)


n = int(input())
p = input()
q = input()
l = []
for i in range(len(p)):
	if p[i] == q[i]:
		pass
	else:
		l.append(i)
if len(l) == 1:
	print(1)
else:
	i = 0
	ans = 0
	while i < len(l) - 1:
		if l[i + 1] - l[i] > 1:
			ans += 1
			l[i] = -1
			i += 1
		elif l[i + 1] - l[i] <= 1:
			if p[l[i]] != p[l[i + 1]]:
				ans += l[i + 1] - l[i]
				l[i] = -1
				l[i + 1] = -1
				i += 2
			else:
				ans += 1
				l[i] = -1
				i += 1
	if len(l) == 0:
		print(0)
	elif l[-1] != -1:
		print(ans + 1)
	else:
		print(ans)


n = int(input())
a = input()
b = input()
s = ''
j = 0
c = 0
while j < n - 1:
	if a[j] != b[j]:
		if a[j + 1] != b[j + 1] and a[j] != a[j + 1]:
			j += 1
			c += 1
		else:
			c += 1
	j += 1
if j == n - 1 and a[j] != b[j]:
	c += 1
print(c)


def read():
	return [c == '1' for c in input()]
n = int(input())
(a, b) = (read(), read())
res = 0
i = 0
while i + 1 < n:
	if a[i] != b[i] and a[i] != a[i + 1] and (b[i] != b[i + 1]):
		a[i] = b[i]
		a[i + 1] = b[i + 1]
		res += 1
		i += 2
	else:
		i += 1
for i in range(n):
	if a[i] != b[i]:
		res += 1
print(res)


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

class FastIO(IOBase):
	newlines = 0

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

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

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

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import gcd, ceil

def pre(s):
	n = len(s)
	pi = [0] * n
	for i in range(1, n):
		j = pi[i - 1]
		while j and s[i] != s[j]:
			j = pi[j - 1]
		if s[i] == s[j]:
			j += 1
		pi[i] = j
	return pi

def prod(a):
	ans = 1
	for each in a:
		ans = ans * each
	return ans

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

def binary(x, length=16):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y
from collections import deque

def bfs(graph, alpha=0):
	n = len(graph)
	order = []
	q = deque([alpha])
	used = [False] * n
	used[alpha] = True
	(dist, parents) = ([0] * n, [-1] * n)
	while q:
		v = q.popleft()
		order += [v]
		for u in graph[v]:
			if not used[u]:
				used[u] = True
				q.append(u)
				dist[u] = dist[v] + 1
				parents[u] = v
	return (used, dist, parents, order)

def shortest_path(graph, alpha, omega):
	(used, dist, parents) = bfs(graph, alpha)
	if not used[omega]:
		return []
	path = [omega]
	v = omega
	while parents[v] != -1:
		path += [parents[v]]
		v = parents[v]
	return path[::-1]
for _ in range(int(input()) if not True else 1):
	n = int(input())
	s1 = input()
	s2 = input()
	ans = 0
	i = 0
	s1 = list(s1)
	while i < n - 1:
		if s1[i] != s2[i] and (s1[i] != s2[i] and s1[i + 1] != s2[i + 1] and (s1[i] != s1[i + 1])):
			(s1[i], s1[i + 1]) = (s1[i + 1], s1[i])
			ans += 1
		i += 1
	for i in range(n):
		if s1[i] != s2[i]:
			ans += 1
	print(ans)


n = int(input())
s = str(input())
t = str(input())
i = 0
ans = 0
while i < n:
	if s[i] != t[i]:
		if i + 1 < n and s[i + 1] != t[i + 1] and (s[i] != s[i + 1]):
			ans = ans + 1
			i = i + 2
		else:
			ans = ans + 1
			i = i + 1
	else:
		i = i + 1
print(ans)


n = int(input())
a = input()
b = input()
count = 0
i = 0
while i < n:
	if a[i] != b[i]:
		if i < n - 1 and a[i + 1] != b[i + 1] and (a[i] != a[i + 1]):
			i += 1
		i += 1
		count += 1
	else:
		i += 1
print(count)


nBits = int(input())
bits = [int(x) for x in list(input())]
target = [int(x) for x in list(input())]
cost = 0
i = 0
while i < nBits - 1:
	if bits[i] == target[i]:
		i += 1
		continue
	if bits[i + 1] != target[i + 1] and bits[i] != bits[i + 1]:
		i += 2
	else:
		i += 1
	cost += 1
if i == nBits - 1 and bits[nBits - 1] != target[nBits - 1]:
	cost += 1
print(cost)


def findMinsteps(s1, s2):
	count = 0
	n = len(s1)
	i = 0
	while i < n:
		if s1[i] == s2[i]:
			i += 1
			continue
		elif i + 1 < n and s1[i + 1] != s2[i + 1] and (s1[i] != s1[i + 1]):
			count += 1
			i += 2
			continue
		else:
			count += 1
			i += 1
	print(count)
l = int(input())
s1 = input()
s2 = input()
findMinsteps(s1, s2)


n = input()
n = int(n)
A = []
S = 0
o = input()
o = list(o)
p = input()
p = list(p)
for i in range(n):
	if int(o[i]) == int(p[i]):
		A.append(0)
	else:
		A.append(1)
c = 0
while c < n:
	if c == n - 1:
		if A[c] == 1:
			S = S + 1
	elif A[c] == 1:
		if A[c + 1] == 1:
			if int(p[c]) == int(p[c + 1]):
				S = S + 1
			elif int(p[c]) != int(p[c + 1]):
				S = S + 1
				c = c + 1
		else:
			S = S + 1
	c = c + 1
print(S)


n = int(input())
a = input()
b = input()
prev = -1
prev_value = -100
cost = 0
for i in range(n):
	if a[i] != b[i]:
		if prev == -1:
			prev = i
			prev_value = int(b[i])
		elif i - prev > 1:
			cost += 1
			prev = i
			prev_value = int(b[i])
		elif 1 - int(b[i]) == prev_value:
			cost += 1
			prev = -1
			prev_value = -1
		else:
			cost += 1
			prev = i
			prev_value = int(b[i])
if prev != -1:
	cost += 1
print(cost)


n = int(input())
a = list(map(int, input().strip()))
b = list(map(int, input().strip()))
res = 0
for j in range(n - 1):
	if a[j] == 0 and a[j + 1] == 1 and (b[j] == 1) and (b[j + 1] == 0):
		res += 1
		a[j] = 1
		a[j + 1] = 0
	elif a[j] == 1 and a[j + 1] == 0 and (b[j] == 0) and (b[j + 1] == 1):
		res += 1
		a[j] = 0
		a[j + 1] = 1
for j in range(n):
	if a[j] != b[j]:
		res += 1
print(res)


n = int(input())
a = [bin(int(i)) for i in input()]
b = [bin(int(i)) for i in input()]
i = 0
count = 0
while i < n:
	if a[i] != b[i]:
		if i < n - 1 and a[i + 1] != a[i] and (a[i + 1] != b[i + 1]):
			count += 1
			i += 2
		else:
			count += 1
			i += 1
	else:
		i += 1
print(count)


n = int(input())
ax = input()
a = list(map(int, ax))
bx = input()
b = list(map(int, bx))
cost = 0
for i in range(0, n - 1):
	if a[i] != b[i]:
		if a[i + 1] == b[i] and a[i] == b[i + 1]:
			(a[i + 1], a[i]) = (a[i], a[i + 1])
			cost += 1
		else:
			a[i] = b[i]
			cost += 1
if a[-1] != b[-1]:
	a[-1] = b[-1]
	cost += 1
print(cost)


n = int(input())
s1 = input()
s2 = input()
l1 = list(s1)
l2 = list(s2)
c = 0
i = 0
while i < n:
	if l1[i] == l2[i]:
		i += 1
	elif i + 1 < n:
		if l1[i] == l2[i + 1] and l1[i + 1] == l2[i] and (l1[i + 1] != l2[i + 1]):
			c += 1
			i += 2
		else:
			c += 1
			i += 1
	else:
		c += 1
		i += 1
if n == 1 and l1[0] != l2[0]:
	print(1)
else:
	print(c)


import collections, atexit, math, sys, bisect
sys.setrecursionlimit(1000000)

def getIntList():
	return list(map(int, input().split()))
try:
	import numpy

	def dprint(*args, **kwargs):
		print(*args, **kwargs, file=sys.stderr)
	dprint('debug mode')
except ModuleNotFoundError:

	def dprint(*args, **kwargs):
		pass
inId = 0
outId = 0
if inId > 0:
	dprint('use input', inId)
	sys.stdin = open('input' + str(inId) + '.txt', 'r')
if outId > 0:
	dprint('use output', outId)
	sys.stdout = open('stdout' + str(outId) + '.txt', 'w')
	atexit.register(lambda : sys.stdout.close())
(N,) = getIntList()
s1 = input() + '0'
s2 = input() + '0'
res = 0
i = 0
while i < N:
	if s1[i] != s2[i]:
		if s1[i + 1] == s2[i] and s2[i + 1] == s1[i]:
			res += 1
			i += 2
			continue
		res += 1
	i += 1
print(res)


from sys import stdin
n = int(stdin.readline())
a = stdin.readline()
b = stdin.readline()
cost = 0
swapping = False
for i in range(n):
	if not swapping:
		if not a[i] == b[i]:
			cost += 1
			if i < n - 1:
				if a[i] == b[i + 1] and b[i] == a[i + 1]:
					swapping = True
	else:
		swapping = False
print(cost)


input()
c = p = 0
for (x, y) in zip(input(), input()):
	p = y != x != p
	c += p
	p *= y
print(c)


n = int(input())
ar = input()
br = input()
ans = 0
i = 0
while i < n:
	if ar[i] != br[i]:
		if i + 1 < n:
			if ar[i + 1] != br[i + 1] and br[i] == ar[i + 1] and (br[i + 1] == ar[i]):
				ans += 1
				i += 1
			else:
				ans += 1
		else:
			ans += 1
	i += 1
print(ans)


from sys import stdin
stdin.readline

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

def it():
	return int(stdin.readline().strip())
n = it()
a = input()
b = input()
ans = 0
i = 0
while i < n:
	if a[i] != b[i]:
		if i < n - 1 and a[i] == b[i + 1] and (a[i + 1] == b[i]):
			i += 1
		ans += 1
	i += 1
print(ans)


def solve(s, t):
	i = 0
	j = 0
	cost = 0
	while i < len(s) - 1 and j < len(t) - 1:
		if s[i] == t[i]:
			i += 1
			j += 1
		elif s[i] == t[i + 1] and s[i + 1] == t[i]:
			cost += 1
			i += 2
			j += 2
		elif s[i] != t[i]:
			cost += 1
			i += 1
			j += 1
	if i == len(s) - 1 and j == len(t) - 1:
		if s[i] != t[i]:
			cost += 1
	return cost
n = int(input())
s = input()
t = input()
ans = solve(s, t)
print(ans)


import sys
import bisect

def get_line():
	return list(map(int, sys.stdin.readline().strip()))

def in1():
	return int(input())
n = in1()
s1 = get_line()
s2 = get_line()
c = 0
p = 0
i = 0
while i < n:
	if s1[i] != s2[i]:
		if i + 1 < n and s1[i + 1] != s2[i + 1] and (s1[i] != s1[i + 1]):
			i += 2
			c += 1
		elif i + 1 < n and s1[i + 1] == s2[i + 1]:
			c += 1
			i += 1
		else:
			c += 1
			i += 1
	else:
		i += 1
print(c)


n = int(input())
a = input()
b = input()
l = [2] * n
for i in range(n):
	if a[i] != b[i] and a[i] == '1':
		l[i] = 1
	elif a[i] != b[i] and a[i] == '0':
		l[i] = 0
i = 0
c = 0
while 1:
	if i < n - 1:
		if l[i] == 1 and l[i + 1] == 0 or (l[i] == 0 and l[i + 1] == 1):
			c += 1
			i += 2
		elif l[i] == 1 or l[i] == 0:
			c += 1
			i += 1
		else:
			i += 1
	else:
		if i == n - 1:
			if l[i] == 1 or l[i] == 0:
				c += 1
		break
print(c)


MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
(n,) = I()
s = input()
t = input()
ans = 0
i = 0
while i < n:
	if i < n - 1 and (s[i] + s[i + 1] == '01' and t[i] + t[i + 1] == '10' or (s[i] + s[i + 1] == '10' and t[i] + t[i + 1] == '01')):
		ans += 1
		i += 2
	elif s[i] != t[i]:
		ans += 1
		i += 1
	else:
		i += 1
print(ans)


n = int(input())
a = input()
b = input()
l1 = []
l2 = []
b1 = []
for i in range(n):
	b1.append(a[i])
i = 0
while i < n - 1:
	if a[i] == '0' and a[i + 1] == '1' and (b[i] == '1') and (b[i + 1] == '0'):
		l1.append(i)
		b1[i] = '1'
		b1[i + 1] = '0'
		i = i + 1
	elif a[i] == '1' and a[i + 1] == '0' and (b[i] == '0') and (b[i + 1] == '1'):
		l2.append(i)
		b1[i] = '0'
		b1[i + 1] = '1'
		i = i + 1
	i = i + 1
t = set(l2)
s = 0
ans = len(l1) + len(l2)
for i in range(n):
	if b[i] != b1[i]:
		ans = ans + 1
print(ans)


input()
cost = 0
i = 0
last_symbol = ''
for (a, b) in zip(input(), input()):
	if last_symbol != a != b:
		cost += 1
		last_symbol = b
	else:
		last_symbol = ''
print(cost)


import math
from decimal import *
import random
n = int(input())
s1 = list(input())
s2 = list(input())
dp = [0 for i in range(n)]
if s1[0] != s2[0]:
	dp[0] = 1
for i in range(1, n):
	if s1[i] != s2[i]:
		if s1[i - 1] == s2[i - 1]:
			dp[i] = dp[i - 1] + 1
		elif s1[i - 1] != s2[i - 1] and s1[i - 1] != s1[i]:
			dp[i] = dp[i - 1]
			(s1[i], s1[i - 1]) = (s1[i - 1], s1[i])
		else:
			dp[i] = dp[i - 1] + 1
	else:
		dp[i] = dp[i - 1]
print(dp[-1])


n = int(input())
a = list(input())
b = list(input())
arr = []
for i in range(n):
	if a[i] != b[i]:
		arr.append(i)
fin = [0] * len(arr)
if len(arr) == 0:
	print(0)
elif len(arr) == 1:
	print(1)
elif len(arr) == 2:
	if a[arr[0]] != a[arr[1]]:
		print(min(2, abs(arr[0] - arr[1])))
	else:
		print(2)
else:
	fin[0] = 1
	if a[arr[0]] != a[arr[1]]:
		fin[1] = min(2, abs(arr[0] - arr[1]))
	else:
		fin[1] = 2
	for i in range(2, len(arr)):
		if a[arr[i]] != a[arr[i - 1]]:
			fin[i] = min(fin[i - 1] + 1, fin[i - 2] + abs(arr[i] - arr[i - 1]))
		else:
			fin[i] = fin[i - 1] + 1
	print(fin[-1])


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


n = int(input())
(a1, a2) = (input(), input())
(i, ans) = (0, 0)
while i < n:
	if a1[i] != a2[i]:
		if i < n - 1 and a1[i] == a2[i + 1] and (a1[i + 1] == a2[i]):
			i += 1
		ans += 1
	i += 1
print(ans)


n = int(input())
a = input()
b = input()
ans = 0
i = 0
while i < n:
	if i == n - 1:
		if a[i] != b[i]:
			ans += 1
			break
	if a[i] == b[i]:
		i += 1
		continue
	else:
		if a[i] == b[i + 1] and a[i + 1] == b[i]:
			ans += 1
			i += 1
		else:
			ans += 1
		i += 1
print(ans)


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 = [c for c in S()]
	t = [c for c in S()]
	r = 0
	for i in range(n):
		if s[i] == t[i]:
			continue
		r += 1
		if i < n - 1 and s[i] == t[i + 1] and (s[i + 1] == t[i]):
			s[i + 1] = '0'
			t[i + 1] = '0'
	return r
print(main())


n = int(input())
a = input()
b = input()
p = [0] * (n + 1)
if a[0] != b[0]:
	p[1] = 1
for i in range(2, n + 1):
	j = i - 1
	if a[j] == b[j]:
		p[i] = p[i - 1]
	else:
		p[i] = p[i - 1] + 1
		if a[j] != a[j - 1] and b[j] != b[j - 1]:
			p[i] = min(p[i], p[i - 2] + 1)
print(p[n])


n = int(input())
s1 = list(input())
s2 = list(input())
cnt = 0
for i in range(n - 1):
	if s1[i] == '0' and s1[i + 1] == '1' and (s2[i] == '1') and (s2[i + 1] == '0'):
		cnt += 1
		s1[i] = '1'
		s1[i + 1] = '0'
	elif s1[i] == '1' and s1[i + 1] == '0' and (s2[i] == '0') and (s2[i + 1] == '1'):
		cnt += 1
		s1[i] = '0'
		s1[i + 1] = '1'
for i in range(n):
	if s1[i] == '0' and s2[i] == '1':
		cnt += 1
		s1[i] = '1'
	elif s1[i] == '1' and s2[i] == '0':
		cnt += 1
		s1[i] = '0'
print(cnt)


def main():
	n = int(input())
	a = input()
	b = input()
	last = None
	cost = 0
	for i in range(n):
		if a[i] != b[i]:
			if last is None:
				cost += 1
				last = a[i]
			elif a[i] == last:
				cost += 1
			else:
				last = None
		else:
			last = None
	print(cost)
main()


n = int(input())
a = input()
b = input()
ans = 0
i = 0
a += '00'
b += '00'
while i < n:
	if a[i] != b[i]:
		if a[i + 1] != b[i + 1] and a[i] == b[i + 1]:
			i += 1
		ans += 1
	i += 1
if n == 1:
	if a[0] == b[0]:
		print(0)
	else:
		print(1)
else:
	print(ans)


import math
import bisect
import heapq
from collections import defaultdict

def egcd(a, b):
	if a == 0:
		return (b, 0, 1)
	else:
		(g, x, y) = egcd(b % a, a)
		return (g, y - b // a * x, x)

def mulinv(b, n):
	(g, x, _) = egcd(b, n)
	if g == 1:
		return x % n

def isprime(n):
	for d in range(2, int(math.sqrt(n)) + 1):
		if n % d == 0:
			return False
	return True

def argsort(ls):
	return sorted(range(len(ls)), key=ls.__getitem__)

def f(p=0):
	if p == 1:
		return map(int, input().split())
	elif p == 2:
		return list(map(int, input().split()))
	elif p == 3:
		return list(input())
	else:
		return int(input())
n = f()
a = f(3)
b = f(3)
res = 0
for i in range(n - 1):
	if a[i] == b[i + 1] and a[i + 1] == b[i] and (a[i] != a[i + 1]):
		a[i] = a[i + 1]
		a[i + 1] = str(abs(int(a[i + 1]) - 1))
		res += 1
for i in range(n):
	if a[i] != b[i]:
		res += 1
print(res)


n = int(input())
a = str(input())
b = str(input())
k = True
result = 0
for i in range(n):
	if a[i] == b[i]:
		if k == False:
			result += 1
		k = True
	elif k == False and z != a[i]:
		result += 1
		k = True
	elif k == False and z == a[i]:
		result += 1
	else:
		k = False
		z = a[i]
if k == False:
	result += 1
print(result)


i1 = int(input())
ar = list(input())
br = list(input())
cost = 0
for i in range(i1 - 1):
	if ar[i] != br[i]:
		if ar[i] == br[i + 1] and ar[i + 1] == br[i]:
			ar[i + 1] = br[i + 1]
			cost += 1
		else:
			cost += 1
if ar[i1 - 1] != br[i1 - 1]:
	cost += 1
print(cost)


n = int(input())
s1 = input()
s2 = input()
p1 = -1
p2 = 0
cost = 0
while p2 < n:
	if s1[p2] == s2[p2]:
		p2 += 1
	elif p1 == -1:
		p1 = p2
		p2 += 1
	elif abs(p1 - p2) == 1 and s1[p1] != s1[p2]:
		cost += 1
		p1 = -1
		p2 += 1
	elif s1[p1] == s1[p2]:
		cost += 1
		p1 = p2
		p2 += 1
	else:
		cost += 1
		p1 = p2
		p2 += 1
if p1 != -1 and s1[p1] != s2[p1]:
	cost += 1
print(cost)


import math
n = int(input())
a = input()
b = input()
i = 0
ans = 0
while i < n:
	if a[i] != b[i]:
		if i + 1 < n and a[i + 1] != b[i + 1] and (a[i] != a[i + 1]):
			ans += 1
			i += 2
		else:
			ans += 1
			i += 1
	else:
		i += 1
print(ans)


import sys
n = int(sys.stdin.readline())
a = sys.stdin.readline()
b = sys.stdin.readline()
(i, sum) = (0, 0)
while i < n - 1:
	if a[i] == b[i]:
		i += 1
		continue
	if a[i + 1] == b[i + 1] or a[i] == a[i + 1]:
		sum += 1
		i += 1
	else:
		sum += 1
		i += 2
if i == n - 1 and a[i] != b[i]:
	sum += 1
print(sum)


number = int(input())
a = list(input())
b = list(input())
i = 0
ans = 0
while i < number:
	if a[i] != b[i]:
		ans += 1
		if i < number - 1 and a[i] == b[i + 1] and (b[i] == a[i + 1]):
			i += 1
	i += 1
print(ans)


_ = input()
A = input()
B = input()
i = 0
cost = 0
while i < len(A):
	if A[i] != B[i]:
		if i + 1 < len(A) and A[i + 1] != B[i + 1] and (A[i] != A[i + 1]):
			cost += 1
			i += 2
		else:
			cost += 1
			i += 1
	else:
		i += 1
print(cost)


import sys
n = sys.stdin.readline()
a = list(str(sys.stdin.readline())[:-1])
s = list(str(sys.stdin.readline())[:-1])
ans = 0
l = len(a)
for i in range(l):
	if a[i] != s[i]:
		ans = ans + 1
		if i < l - 1:
			if a[i + 1] != s[i + 1] and a[i + 1] == s[i]:
				a[i + 1] = s[i + 1]
print(ans)


n = int(input())
a = [char for char in input()]
b = [char for char in input()]

def troca(pos):
	if a[pos] == '0':
		a[pos] = '1'
	else:
		a[pos] = '0'
total = 0
for i in range(n):
	if a[i] != b[i]:
		if i == n - 1:
			total += 1
		elif a[i] != a[i + 1] and a[i + 1] != b[i + 1]:
			total += 1
			troca(i)
			troca(i + 1)
		else:
			total += 1
print(total)


from __future__ import print_function
import sys
from collections import deque, defaultdict
import math
import functools
import itertools
from bisect import bisect_left, bisect_right
import operator
import heapq
from random import random, randint, randrange, shuffle
true = True
false = False
null = None
reduce = functools.reduce
SLOW = __debug__
try:
	range = xrange
except:
	pass

def fast():
	global SLOW
	SLOW = False

def compute(f, v):
	return f(v)

def seq(lo, hi, step=1):
	return range(lo, hi + 1, step)

def sround(val, nd):
	return '{0:.{1}f}'.format(val, nd)

def ceil(a, b):
	ans = a // b
	if a % b != 0:
		ans += 1
	return ans

def e1e(d, e):
	return d * 10 ** e
mod = e1e(1, 9) + 7
try:
	memoi = functools.lru_cache(None)
except:

	class memoize(dict):

		def __init__(self, f):
			self.f = f

		def __call__(self, *args):
			return self[args]

		def __missing__(self, key):
			ans = self[key] = self.f(*key)
			return ans
	memoi = memoize

class ndarray(list):

	def __init__(self, defval, sizes):
		self.sizes = sizes
		self.dimension = len(sizes)
		self.pm = pm = list(sizes)
		pm.append(1)
		for ii in reversed(range(self.dimension)):
			pm[ii] *= pm[ii + 1]
		list.__init__(self, [defval] * pm[0])

	def ___i1d___(self, ixs):
		if SLOW:
			assert len(ixs) == self.dimension, 'Dimension must be {}.'.format(self.dimension)
		ans = 0
		for ii in range(self.dimension):
			ix = ixs[ii]
			if SLOW:
				assert ix < self.sizes[ii], 'Index[{}]={} >= Len[{}]={}.'.format(ii, ix, ii, self.sizes[ii])
			ans += ix * self.pm[ii + 1]
		return ans

	def __getitem__(self, ixs):
		ixs = self.___i1d___(ixs)
		return list.__getitem__(self, ixs)

	def __setitem__(self, ixs, val):
		ixs = self.___i1d___(ixs)
		list.__setitem__(self, ixs, val)

	def _str_(self, dim0=0, ofs=0):
		lft = '  ' * dim0
		if dim0 + 1 == self.dimension:
			return lft + str(list.__getitem__(self, slice(ofs, ofs + self.sizes[dim0])))
		ans = []
		for ii in range(self.sizes[dim0]):
			ans.append(self._str_(dim0 + 1, ofs))
			ofs += self.pm[dim0 + 1]
		ans = '{0}[\n{1}\n{0}]'.format(lft, ',\n'.join(ans))
		return ans

	def __str__(self):
		return self._str_()

def arrays(defval, *sizes):
	if len(sizes) == 1:
		return [defval] * sizes[0]
	return ndarray(defval, sizes)

def perr(*args, **kwargs):
	if SLOW:
		print(*args, file=sys.stderr, **kwargs)

def line():
	ln = sys.stdin.readline().strip()
	if ln == '':
		sys.exit()
	return ln

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

def split(ln=None):
	return (ln or line()).split()

def num(str=None):
	str = str or line()
	return float(str) if '.' in str else int(str)

def nums(o=None):
	if o is not None:
		if isinstance(o, int):
			o = lines(o)
	return list(map(num, o or split()))

def loop(f, n=0):
	for tcid in range(n or 99999999):
		f(tcid + 1)

def repeat(n, f):
	for _ in range(n):
		yield f()

def recursi(root, fchildren, ctop):
	p = deque()
	c = deque()
	q = deque()
	q.append(root)
	while len(q) > 0:
		pp = q.popleft()
		for cc in fchildren(pp):
			p.append(pp)
			c.append(cc)
			q.append(cc)
	for _ in range(len(p)):
		ctop(c.pop(), p.pop())

def summod(*args):
	sums = 0
	for vv in args:
		sums = (sums + vv) % mod
	return sums

def multmod(*args):
	ans = 0
	for vv in args:
		ans = (ans + vv) % mod
	return ans

def subsmod(*args):
	ans = 0
	for vv in args:
		ans = (ans + mod - vv) % mod
	return ans

def matmultmod(a, b):
	ra = len(a)
	ca = len(a[0])
	rb = len(b)
	cb = len(b[0])
	if SLOW:
		assert ca == rb, 'matrix incompatible size'
	return [[summod(*map(lambda ii: a[rr][ii] * b[ii][cc], range(ca))) for cc in range(cb)] for rr in range(ra)]

def mainloop(tcid):
	ignored = 1
	n = num()
	a = line()
	b = line()
	dp = arrays(n, n + 1)
	dp[0] = 0

	def upd(dp, i, nv):
		dp[i] = min(dp[i], nv)
	cc = map(lambda xx, yy: 0 if xx == yy else int(xx) + 1, a, b)
	cc = list(cc)
	for ii in range(n):
		upd(dp, ii + 1, dp[ii] + int(cc[ii] > 0))
		if ii + 1 < n and cc[ii] | cc[ii + 1] == 3:
			upd(dp, ii + 2, dp[ii] + 1)
	print(dp[n])
tcmax = 0
loop(mainloop, tcmax)


t = 1
while t > 0:
	n = int(input())
	a = input()
	b = input()
	cost = 0
	i = 0
	while i < n:
		if a[i] != b[i]:
			if i == n - 1:
				pass
			elif a[i] == b[i + 1] and a[i + 1] == b[i]:
				i += 1
			else:
				pass
			cost += 1
		i += 1
	print(cost)
	t -= 1


n = int(input())
a = list(map(int, input()))
b = list(map(int, input()))
ans = sum((q != w for (q, w) in zip(a, b)))
i = 1
while i < n:
	aii = a[i - 1]
	ai = a[i]
	bii = b[i - 1]
	bi = b[i]
	if aii + ai == 1 and bii + bi == 1 and (aii != bii) and (ai != bi):
		ans -= 1
		i += 1
	i += 1
print(ans)


n = int(input())
a = list(input())
b = list(input())
(l, p) = ([], [])
(i, c) = (0, 0)
while i < n:
	if a[i] != b[i]:
		if i + 1 < n and a[i + 1] != a[i] and (a[i + 1] != b[i + 1]):
			c += 1
			i += 2
		else:
			c += 1
			i += 1
	else:
		i += 1
print(c)


import sys

def input():
	return sys.stdin.readline().rstrip('\n')
n = int(input())
a = input()
b = input()
idx = []
for i in range(n):
	if a[i] != b[i]:
		idx.append(i)
cost = 0
for i in range(1, len(idx)):
	if idx[i - 1] != None:
		if a[idx[i]] != a[idx[i - 1]] and idx[i] - idx[i - 1] == 1:
			cost += 1
			(idx[i - 1], idx[i]) = (None, None)
for i in idx:
	if i != None:
		cost += 1
print(cost)


from sys import stdin, stdout

def main():
	n = int(stdin.readline())
	a = list(stdin.readline())
	b = list(stdin.readline())
	ans = 0
	for i in range(n - 1):
		if a[i] != b[i] and a[i + 1] != b[i + 1]:
			if a[i] == b[i + 1] and a[i + 1] == b[i]:
				(a[i], a[i + 1]) = (a[i + 1], a[i])
				ans += 1
	for i in range(n):
		if a[i] != b[i]:
			ans += 1
	stdout.write('%d' % ans)
main()


size = int(input())
a = input()
b = input()
soma = 0
diff = []
for i in range(size):
	if a[i] != b[i]:
		if len(diff) > 0 and diff[-1] + 1 == i:
			k = diff[-1]
			if a[i] == b[k] and a[k] == b[i]:
				diff.pop()
				soma += 1
			else:
				diff.append(i)
		elif len(diff) > 0 and diff[-1] + 1 < i:
			diff.append(i)
		elif len(diff) == 0:
			diff.append(i)
soma += len(diff)
print(soma)


n = int(input())
a = input()
b = input()
ans = []
for i in range(len(a)):
	if a[i] != b[i]:
		ans.append(i)
dici = {}
for i in ans:
	dici[i] = False
count = 0
for i in range(len(ans) - 1):
	if dici[ans[i]] == False and dici[ans[i + 1]] == False:
		if ans[i + 1] - ans[i] == 1 and a[ans[i + 1]] != a[ans[i]]:
			count += 1
			dici[ans[i + 1]] = True
			dici[ans[i]] = True
		else:
			continue
for i in dici.values():
	if i == False:
		count += 1
print(count)


n = int(input())
a = input()
b = input()
result = 0
index = 0
while index < n - 1:
	if a[index] != b[index]:
		if a[index] != a[index + 1] and a[index + 1] != b[index + 1]:
			result += 1
			index += 2
		else:
			result += 1
			index += 1
	else:
		index += 1
if index == n - 1:
	if a[index] != b[index]:
		result += 1
print(result)


from __future__ import division, print_function
from sys import stdin, stdout
import itertools, os, sys, threading
from collections import deque, Counter, OrderedDict, defaultdict
import heapq
from fractions import Fraction
import math

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

def si():
	return str(input())

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

def li():
	return list(mi())

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

def fsi():
	return str(stdin.readline())

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

def fli():
	return list(fmi())
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[0]

def sort2(l):
	return sorted(l, key=getKey)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

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

def ntl(n):
	return [int(i) for i in str(n)]

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
graph = defaultdict(list)
visited = [0] * 1000000
col = [-1] * 1000000

def dfs(v, c):
	if visited[v]:
		if col[v] != c:
			print('-1')
			exit()
		return
	col[v] = c
	visited[v] = 1
	for i in graph[v]:
		dfs(i, c ^ 1)

def bfs(d, v):
	q = []
	q.append(v)
	visited[v] = 1
	while len(q) != 0:
		x = q[0]
		q.pop(0)
		for i in d[x]:
			if visited[i] != 1:
				visited[i] = 1
				q.append(i)
		print(x)

def make_graph(e):
	d = defaultdict(list)
	for i in range(e):
		(x, y) = mi()
		d[x].append(y)
		d[y].append(x)
	return d

def gr2(n):
	d = defaultdict(list)
	for i in range(n):
		(x, y) = mi()
		d[x].append(y)
	return d

def connected_components(graph):
	seen = set()

	def dfs(v):
		vs = set([v])
		component = []
		while vs:
			v = vs.pop()
			seen.add(v)
			vs |= set(graph[v]) - seen
			component.append(v)
		return component
	ans = []
	for v in graph:
		if v not in seen:
			d = dfs(v)
			ans.append(d)
	return ans

def primeFactors(n):
	s = set()
	while n % 2 == 0:
		s.add(2)
		n = n // 2
	for i in range(3, int(sqrt(n)) + 1, 2):
		while n % i == 0:
			s.add(i)
			n = n // i
	if n > 2:
		s.add(n)
	return s

def find_all(a_str, sub):
	start = 0
	while True:
		start = a_str.find(sub, start)
		if start == -1:
			return
		yield start
		start += len(sub)

def SieveOfEratosthenes(n, isPrime):
	isPrime[0] = isPrime[1] = False
	for i in range(2, n + 1):
		isPrime[i] = True
	p = 2
	while p * p <= n:
		if isPrime[p] == True:
			i = p * p
			while i <= n:
				isPrime[i] = False
				i += p
		p += 1
n = ii()
s = si()
t = si()
i = 0
count = 0
while i < n:
	f = 0
	if i < n - 1:
		if s[i] == '1' and s[i + 1] == '0' and (t[i] == '0') and (t[i + 1] == '1'):
			f = 1
			count += 1
			i += 1
		elif s[i] == '0' and s[i + 1] == '1' and (t[i] == '1') and (t[i + 1] == '0'):
			f = 1
			count += 1
			i += 1
	if s[i] != t[i] and f == 0:
		count += 1
	i += 1
print(count)


n = int(input())
a = input()
b = input()
arr = [False] * n
sum = 0
i = 0
while i < n - 1:
	if a[i:i + 2] == '01' and b[i:i + 2] == '10' or (a[i:i + 2] == '10' and b[i:i + 2] == '01'):
		sum += 1
		arr[i] = True
		arr[i + 1] = True
		i += 1
	i += 1
for i in range(n):
	if not arr[i] and a[i] != b[i]:
		sum += 1
print(sum)


n = int(input())
a = input()
b = input()
a = list(a)
b = list(b)
z = 0
w = -2
for i in range(n):
	if a[i] != b[i]:
		z = z + 1
		if w == i and a[i] != a[i - 1]:
			z -= 1
			w = -1
		if w == -1:
			w = 0
		else:
			w = i + 1
print(z)


n = int(input())
a = input()
b = input()
index = []
for i in range(n):
	if a[i] != b[i]:
		index.append(i)
j = 0
ans = 0
visit = []
while j < len(index):
	if j + 1 < len(index) and abs(index[j] - index[j + 1]) == 1:
		if a[index[j]] != a[index[j + 1]] and a[index[j]] == b[index[j + 1]] and (a[index[j + 1]] == b[index[j]]):
			ans += 1
			visit.append(index[j])
			visit.append(index[j + 1])
			j += 2
		else:
			j += 1
	else:
		j += 1
ans += len(set(index) - set(visit))
print(ans)


input()
a = 0
counter = 0
for (i, j) in zip(input(), input()):
	a = j != i != a
	counter += a
	a *= j
print(counter)


n = int(input())
a = input()
b = input()
i = 0
cost = 0
while i < n:
	if a[i] == b[i]:
		i += 1
	elif a[i] != b[i] and i + 1 < n and (a[i + 1] != b[i + 1]) and (a[i] != a[i + 1]):
		i += 2
		cost += 1
	else:
		i += 1
		cost += 1
print(cost)


n = int(input())
a = input()
b = input()
cost = 0
c = n * [0]
for i in range(n):
	if a[i] == b[i]:
		c[i] = 1
i = 0
while i < n - 1:
	if c[i]:
		i += 1
		continue
	elif not c[i + 1] and a[i] != a[i + 1]:
		cost += 1
		i += 2
	else:
		cost += 1
		i += 1
if i == n - 1:
	if not c[n - 1]:
		cost += 1
print(cost)


def getMinCost(a, b, n):
	i = 0
	cost = 0
	while i < n - 1:
		if a[i] != b[i] and a[i] != a[i + 1] and (a[i + 1] != b[i + 1]):
			i += 2
			cost += 1
		elif a[i] != b[i]:
			i += 1
			cost += 1
		else:
			i += 1
	if i < n and a[i] != b[i]:
		cost += 1
	return cost
n = int(input())
a = input()
b = input()
print(getMinCost(a, b, n))


def sol():
	N = int(input())
	A = list(input())
	B = list(input())
	cost = 0
	for i in range(len(A) - 1):
		if A[i] == B[i]:
			continue
		t1 = (A[i + 1], A[i])
		t2 = (B[i], B[i + 1])
		if t1 == t2:
			A[i + 1] = B[i + 1]
		cost += 1
	if A[-1] != B[-1]:
		cost += 1
	print(cost)
sol()


n = int(input())
a = input()
b = input()
count = 0
c = ''
for i in range(0, n):
	if c != a[i] != b[i]:
		count = count + 1
		c = b[i]
	else:
		c = ''
print(count)


I = lambda : map(int, input().split())
n = int(input())
a = list(input())
b = list(input())
count = total = 0
for i in range(n):
	if a[i] != b[i]:
		total += 1
i = 1
while i < n:
	if a[i] != b[i]:
		if a[i] != a[i - 1]:
			if b[i] != b[i - 1]:
				count += 1
				i += 2
			else:
				i += 1
		else:
			i += 1
	else:
		i += 1
print(total - count)


import traceback
import math
from collections import defaultdict
from functools import lru_cache
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

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

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

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

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

class IOWrapper(IOBase):

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

def geti():
	return int(input())

def gets():
	return input()

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

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

def get2d(nrows, ncols, n=0):
	return [[n] * ncols for r in range(nrows)]
inf = float('inf')
mod = 10 ** 9 + 7

def main():
	N = geti()
	a = gets()
	b = gets()
	i = ans = 0
	while i < N:
		if a[i] == b[i]:
			i += 1
		elif i + 1 < N and a[i] != b[i] and (a[i + 1] != b[i + 1]) and (a[i] != a[i + 1]):
			ans += 1
			i += 2
		else:
			ans += 1
			i += 1
	return ans
try:
	ans = main()
	print(ans)
except Exception as e:
	traceback.print_exc()


n = int(input())
a = input()
b = input()
c = [10 ** 10 for i in range(n + 10)]
c[0] = 0 if a[0] == b[0] else 1
for i in range(1, n):
	if a[i] == b[i]:
		c[i] = c[i - 1]
	elif a[i] == b[i - 1] and a[i - 1] == b[i]:
		c[i] = 1 + c[i - 2] if i > 1 else 1
	c[i] = min(c[i], c[i - 1] + 1)
print(c[n - 1])


import sys, heapq
n = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().rstrip()))
b = list(map(int, sys.stdin.readline().rstrip()))
temp = []
for i in range(n):
	if a[i] != b[i]:
		heapq.heappush(temp, i)
size = len(temp)
ans = 0
while len(temp) >= 2:
	first = heapq.heappop(temp)
	second = heapq.heappop(temp)
	if a[first] == 1 and a[second] == 0 and (b[first] == 0) and (b[second] == 1) or (a[first] == 0 and a[second] == 1 and (b[first] == 1) and (b[second] == 0)):
		if second - first < 2:
			ans += second - first
		else:
			ans += 1
			heapq.heappush(temp, second)
	else:
		ans += 1
		heapq.heappush(temp, second)
if temp:
	ans += len(temp)
print(ans)


n = int(input())
(s1, s2) = (input(), input())
(cost, check) = (0, 0)
for ch in range(n):
	if s2[ch] != s1[ch] != check:
		cost += 1
		check = s2[ch]
	else:
		check = 0
print(cost)


n = int(input())
a = input()
b = input()
cost = 0
flag = False
for (i, char) in enumerate(a):
	if flag or char == b[i]:
		flag = False
		continue
	if i < n - 1 and a[i] != a[i + 1] and (a[i + 1] != b[i + 1]):
		flag = True
	cost += 1
print(cost)


n = int(input())
s = list(input())
s1 = input()
ans = 0
for i in range(n):
	if s[i] != s1[i]:
		if i != n - 1 and s[i] != s[i + 1] and (s1[i + 1] != s1[i]):
			s[i] = s1[i]
			s[i + 1] = s1[i + 1]
		else:
			s[i] = s1[i]
		ans += 1
print(ans)


import sys
import math
import collections
import bisect

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

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

def get_string():
	return sys.stdin.readline().strip()
for t in range(1):
	n = int(input())
	a = list(get_string())
	b = list(get_string())
	cost = 0
	for i in range(n):
		ele_a = a[i]
		ele_b = b[i]
		if ele_a == ele_b:
			continue
		else:
			for j in range(i + 1, min(n, i + 2)):
				if a[j] == ele_b and a[j] != b[j]:
					cost += abs(j - i)
					(a[j], a[i]) = (a[i], a[j])
	for i in range(n):
		if a[i] == b[i]:
			continue
		else:
			cost += 1
	print(cost)


n = int(input())
a = input()
b = input()
not_coincedence = 0
permutations = 0
i = 0
while i < n:
	if a[i] != b[i]:
		if i < n - 1:
			if a[i] == '1':
				if a[i + 1] == '0' and b[i + 1] != '0':
					permutations += 1
					i += 1
			elif a[i + 1] == '1' and b[i + 1] != '1':
				permutations += 1
				i += 1
	i += 1
for j in range(n):
	if a[j] != b[j]:
		not_coincedence += 1
result = not_coincedence - permutations
print(result)


l = lambda : map(int, input())
p = lambda : int(input())
ss = lambda : input()
n = p()
a = list(l())
b = ss()
c = 0
for j in range(n - 1):
	if a[j] != int(b[j]):
		if a[j + 1] == int(b[j]) and int(b[j + 1]) != a[j + 1]:
			c += 1
			(a[j], a[j + 1]) = (a[j + 1], a[j])
		else:
			c += 1
			a[j] = int(b[j])
if a[-1] != int(b[-1]):
	c += 1
print(c)


def split(word):
	return [char for char in word]
size = int(input())
a = list(input())
b = list(input())
count = 0
for i in range(size):
	if a[i] != b[i]:
		if i + 1 < size:
			if a[i + 1] != b[i + 1] and a[i] != a[i + 1]:
				a[i] = b[i]
				a[i + 1] = b[i + 1]
				count += 1
			else:
				a[i] = b[i]
				count += 1
		else:
			a[i] = b[i]
			count += 1
print(count)


n = int(input())
a = input()
b = input()
(i, answer) = (0, 0)
while i < n:
	if a[i] != b[i]:
		if i < n - 1 and a[i] == b[i + 1] and (a[i + 1] == b[i]):
			i += 1
		answer += 1
	i += 1
print(answer)


n = int(input())
a = input()
b = input()
a = list(a)
b = list(b)
moves = 0
k = 0
for i in range(n - 1):
	if a[i] != b[i] and a[i + 1] != a[i] and (a[i + 1] != b[i + 1]):
		c = a[i]
		a[i] = a[i + 1]
		a[i + 1] = c
		moves += 1
		i = i + 2
		k = 1
	elif a[i] != b[i]:
		a[i] = b[i]
		moves += 1
		k = 0
	else:
		k = 0
if k == 0 and a[n - 1] != b[n - 1]:
	moves += 1
	a[n - 1] = b[n - 1]
print(moves)


length = int(input())
ls1 = input()
ls2 = input()
str1 = list(ls1)
str2 = list(ls2)
count = 0
for i in range(0, len(str1)):
	if str1[i] == str2[i]:
		pass
	elif str1[i] == '0' and str2[i] == '1' and (i + 1 < len(str1)) and (str1[i + 1] == '1' and str2[i + 1] == '0'):
		temp = str1[i]
		str1[i] = str1[i + 1]
		str1[i + 1] = temp
		count += 1
	elif str1[i] == '1' and str2[i] == '0' and (i + 1 < len(str1)) and (str1[i + 1] == '0' and str2[i + 1] == '1'):
		temp = str1[i]
		str1[i] = str1[i + 1]
		str1[i + 1] = temp
		count += 1
	else:
		str1[i] = str2[i]
		count += 1
print(count)


n = int(input())
a = input()
b = input()
changed = []
if n == 1:
	if a != b:
		print(1)
	else:
		print(0)
	exit()
else:
	cost = 0
	if a[0] != b[0]:
		cost = 1
	for i in range(1, n):
		if a[i] != b[i]:
			cost = cost + 1
			if a[i] != a[i - 1] and a[i - 1] != b[i - 1] and (i - 1 not in changed):
				cost = cost - 1
				changed = []
				changed.append(i)
print(cost)


from itertools import permutations
from collections import defaultdict
from math import *
import os
import sys
from io import BytesIO, IOBase
from heapq import nlargest
from bisect import *
import copy
import itertools
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

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

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

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

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
n = int(input())
arr = input()
brr = input()
i = 0
ans = 0
isdiffer = False
for i in range(n):
	if arr[i] == brr[i]:
		if isdiffer == True:
			ans += 1
		isdiffer = False
	elif isdiffer:
		if arr[i] != arr[i - 1]:
			ans += 1
			isdiffer = False
		else:
			ans += 1
			isdiffer = True
	else:
		isdiffer = True
if isdiffer:
	ans += 1
print(ans)


n = int(input())
a = input()
b = input()
ans = 0
s = n * [0]
for t in range(n):
	if a[t] == b[t]:
		continue
	elif a[t:t + 2] == b[t:t + 2][::-1] and t + 1 != n and (s[t] == 0):
		ans += 1
		s[t + 1] = 1
	elif s[t] == 0:
		ans += 1
print(ans)


from sys import stdin, stdout
n = int(stdin.readline())
a = stdin.readline()[:-1] + '0'
b = stdin.readline()[:-1] + '0'
ans = 0
flag = False
for i in range(0, n):
	c = a[i]
	if flag:
		c = '0' if a[i] == '1' else '1'
	flag = False
	if c == b[i]:
		continue
	if a[i + 1] == b[i] and a[i + 1] != b[i + 1]:
		flag = True
	ans += 1
print(ans)


import math, sys
import heapq
from fractions import Fraction
from collections import Counter, defaultdict

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

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

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

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

def dic(x):
	return defaultdict(lambda : x)

def isPrime(n):
	i = 2
	if n == 1:
		return False
	while i <= int(math.sqrt(n)):
		if n % i == 0:
			return False
		i = i + 1
	return True

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

def LCM(a, b):
	return a * b / gcd(a, b)
n = ii()
a = la()
b = la()
i = 0
total = 0
while i < n:
	if a[i] != b[i]:
		if i + 1 < n:
			if a[i] == b[i + 1] and a[i + 1] == b[i]:
				a[i] = b[i + 1]
				a[i + 1] == b[i]
				total += 1
				i = i + 1
			else:
				total += 1
		else:
			total += 1
	i = i + 1
print(total)


x = int(input())
a = input()
b = input()
c = 0
i = 0
f = 1
while i < x - 1:
	if a[i] != b[i]:
		if a[i] != a[i + 1] and b[i] != b[i + 1]:
			c += 1
			if i == x - 2:
				f = 0
			i += 2
		else:
			c += 1
			i += 1
	else:
		i += 1
if a[x - 1] != b[x - 1] and f == 1:
	c += 1
print(c)


def solve():
	n = int(input())
	a = input()
	b = input()
	ans1 = 0
	ans = 0 if a[0] == b[0] else 1
	for i in range(1, n):
		nans = ans + (a[i] != b[i])
		if a[i] != a[i - 1] and a[i] == b[i - 1] and (a[i - 1] == b[i]):
			nans = min(nans, ans1 + 1)
		(ans, ans1) = (nans, ans)
	print(ans)
solve()


from sys import stdin, stdout
import cProfile
printHeap = str()
test = False
memory_constrained = False

def display(string_to_print):
	stdout.write(str(string_to_print) + '\n')

def test_print(output):
	if test:
		stdout.write(str(output) + '\n')

def display_list(list1, sep=' '):
	stdout.write(sep.join(map(str, list1)) + '\n')

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

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

def get_list():
	return list(map(int, stdin.readline().split()))
memory = dict()

def clear_cache():
	global memory
	memory = dict()

def cached_fn(fn, *args):
	global memory
	if args in memory:
		return memory[args]
	else:
		result = fn(*args)
		memory[args] = result
		return result

def main():
	n = get_int()
	s1 = list(map(int, list(stdin.readline().strip())))
	s2 = list(map(int, list(stdin.readline().strip())))
	(cost, i) = (0, 0)
	while i < n:
		if s1[i] is not s2[i]:
			if i + 1 != n and s1[i + 1] is not s2[i + 1] and (s1[i] is not s1[i + 1]):
				i += 1
			cost += 1
		i += 1
	print(cost)
cProfile.run('main()') if test else main()


I = lambda : int(input())
ID = lambda : map(int, input().split())
IL = lambda : list(ID())
n = I()
a = input()
b = input()
f = False
ans = 0
for i in range(n):
	if a[i] != b[i]:
		if f and a[i] != a[i - 1]:
			f = False
		else:
			ans += 1
			f = True
	else:
		f = False
print(ans)


n = int(input())
a = [int(i) for i in input()]
b = [int(i) for i in input()]
t = 0
s = 0
while t < n:
	if a[t] == b[t]:
		t += 1
	elif t + 1 < n:
		if a[t + 1] != b[t + 1]:
			if a[t] != a[t + 1]:
				s += 1
				t += 2
			else:
				s += 1
				t += 1
		else:
			s += 1
			t += 1
	else:
		s += 1
		t += 1
print(s)


n = int(input())
str1 = input()
str2 = input()
lst1 = [0] * n
lst2 = [0] * n
pre_zero = -1
pre_one = -1
i = 0
while i < n:
	if str1[i] == str2[i]:
		lst1[i] = lst1[i - 1]
	elif str1[i] == '0':
		if pre_one == -1:
			lst1[i] = lst1[i - 1] + 1
		else:
			lst1[i] = min(lst1[pre_one - 1] + abs(pre_one - i), lst1[i - 1] + 1)
		pre_zero = i
	elif str1[i] == '1':
		if pre_zero == -1:
			lst1[i] = lst1[i - 1] + 1
		else:
			lst1[i] = min(lst1[pre_zero - 1] + abs(pre_zero - i), lst1[i - 1] + 1)
		pre_one = i
	i += 1
print(lst1[n - 1])


n = int(input())
a = input()
b = input()
c = False
f = 0
l = '12'
for i in range(n):
	if a[i] != b[i]:
		if c:
			if l != a[i]:
				c = False
				f += 1
			else:
				f += 1
		else:
			c = True
	else:
		if c:
			f += 1
		c = False
	l = a[i]
if c:
	f += 1
print(f)


n = int(input())
s1 = input() + '9'
s2 = input() + '9'
c = 0
i = 0
while i < n:
	if s1[i] != s2[i]:
		if s1[i] == s2[i + 1] and s1[i + 1] == s2[i]:
			c += 1
			i += 2
		else:
			c += 1
			i += 1
	else:
		i += 1
print(c)


for _ in range(1):
	n = input()
	a = input()
	a = [i for i in a]
	b = input()
	count = 0
	for i in range(len(a)):
		if a[i] != b[i]:
			if i + 1 < len(a) and b[i] == a[i + 1] and (a[i] == b[i + 1]):
				(a[i + 1], a[i]) = (a[i], a[i + 1])
			count += 1
	print(count)


input()
c = p = 0
for (x, y) in zip(input(), input()):
	f = y != x != p
	c += f
	p = f and y
print(c)


import sys

def main():
	n = int(sys.stdin.readline())
	a = sys.stdin.readline()
	b = sys.stdin.readline()
	delta = 0
	i = 0
	while i < n - 1:
		if a[i] == b[i]:
			i += 1
		elif a[i] != b[i] and a[i + 1] != b[i + 1] and (a[i] != a[i + 1]):
			i += 2
			delta += 1
		else:
			i += 1
			delta += 1
	if i < n and a[i] != b[i]:
		delta += 1
	return delta
print(main())


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


n = int(input())
s1 = input()
s2 = input()
cnt = 0
i = 0
s1 += '/'
s2 += '/'
while i < n:
	if s1[i] != s2[i]:
		if s1[i] == s2[i + 1] and s1[i + 1] == s2[i]:
			cnt += 1
			i += 2
		else:
			cnt += 1
			i += 1
	else:
		i += 1
print(cnt)


n = int(input())
r = n - 1
s = list(input())
t = list(input())
count = 0
k = False
for i in range(n):
	if s[i] == t[i] or k:
		k = False
		continue
	elif i != r and s[i + 1] != s[i] and (s[i] == t[i + 1]):
		count += 1
		k = True
	else:
		count += 1
print(count)


n = int(input())
a = input()
b = input()
ANS = 0
i = 0
while i < n:
	if a[i] == b[i]:
		i += 1
		continue
	if i + 1 < n and a[i + 1] != a[i] and (a[i] == b[i + 1]):
		ANS += 1
		i += 2
		continue
	else:
		ANS += 1
		i += 1
print(ANS)


n = int(input())
a = input()
b = input()
ans = 0
for i in range(len(a)):
	ans += abs(int(a[i]) - int(b[i]))
i = 0
while i < len(a) - 1:
	if a[i] == '1' and a[i + 1] == '0' and (b[i] == '0') and (b[i + 1] == '1') or (a[i] == '0' and a[i + 1] == '1' and (b[i] == '1') and (b[i + 1] == '0')):
		ans -= 1
		i += 1
	i += 1
print(ans)


n = int(input())
A = list(input())
B = list(input())
ans = 0
for i in range(n - 1):
	if A[i] != B[i]:
		if A[i + 1] != B[i + 1] == A[i]:
			ans += 1
			A[i] = B[i]
			A[i + 1] = B[i + 1]
		else:
			ans += 1
if A[n - 1] != B[n - 1]:
	ans += 1
print(ans)


n = int(input())
a = input()
b = input()
count = 0
lst = []
index = 0
while index + 1 < n:
	if a[index] != b[index]:
		count += 1
		if a[index] != a[index + 1] and a[index] == b[index + 1]:
			index += 1
	index += 1
if index < n and a[index] != b[index]:
	count += 1
print(count)


def mp():
	return map(int, input().split())
n = int(input())
a = [i for i in input()] + ['0']
b = [i for i in input()] + ['0']
ans = 0
for i in range(n):
	if a[i] == b[i]:
		continue
	if a[i + 1] == b[i] and a[i] == b[i + 1]:
		(a[i], a[i + 1]) = (a[i + 1], a[i])
	else:
		a[i] = b[i]
	ans += 1
print(ans)


import sys
import os.path
import math
from collections import deque
if os.path.exists('input_file.txt'):
	sys.stdin = open('input_file.txt', 'r')
	sys.stdout = open('output_file.txt', 'w')
no = int(input())
a1 = list(input())
a2 = list(input())
ans = 0
for i in range(no):
	if i == no - 1:
		if a1[i] != a2[i]:
			ans += 1
	elif a1[i] != a2[i]:
		if a1[i + 1] != a2[i + 1] and a1[i] == a2[i + 1]:
			ans += 1
			(a1[i], a1[i + 1]) = (a1[i + 1], a1[i])
		else:
			ans += 1
print(ans)


def solve():
	n = int(input())
	a = input()
	b = input()
	dp = [0 for i in range(n)]
	if n == 1:
		return 1 if a != b else 0
	dp[0] = int(a[0] != b[0])
	if a[:2] == b[:2]:
		dp[1] = 0
	elif a[:2] == b[:2][::-1]:
		dp[1] = 1
	else:
		dp[1] = dp[0] + int(a[1] != b[1])
	for i in range(2, n):
		dp[i] = dp[i - 1] + int(a[i] != b[i])
		if a[i] == b[i - 1] and b[i] == a[i - 1]:
			dp[i] = min(dp[i], dp[i - 2] + 1)
	return dp[-1]
print(solve())


def ravenstvo(s, t):
	(count, prev) = (0, 0)
	for i in range(len(s)):
		if i + 1 <= len(s) and s[i] == t[i]:
			prev = i + 1
		else:
			if i + 1 <= len(s) and s[prev] != s[i] and (s[prev] != t[prev]):
				prev = i + 1
				continue
			count += 1
			prev = i
	return count
n = int(input())
a = input()
b = input()
print(ravenstvo(a, b))


n = int(input())
(a, b) = (input() + ' ', input() + ' ')
res = 0
i = 0
while i < n:
	if a[i] != b[i]:
		res += 1
		if a[i + 1] != b[i + 1] and a[i] + a[i + 1] in '101':
			i += 1
	i += 1
print(res)


n = int(input())
a = input()
b = input()
a = list(a)
b = list(b)
ile = 0
for i in range(len(a)):
	if i < n - 1 and a[i] == b[i + 1] and (a[i + 1] == b[i]) and (a[i] != a[i + 1]):
		a[i] = b[i]
		a[i + 1] = b[i + 1]
		ile += 1
for i in range(n):
	if a[i] != b[i]:
		ile += 1
print(ile)


n = int(input())
a = input()
b = input()
res = 0
for i in range(n):
	if a[i] != b[i]:
		res += 1
i = 0
c = 0
while i < n - 1:
	if a[i] != b[i] and a[i] != a[i + 1] and (b[i] != b[i + 1]):
		c += 1
		i += 1
	i += 1
print(res - c)


i = int(input())
a = [k for k in input()]
b = [k for k in input()]
cost = 0
k = 0
while k < i:
	if a[k] != b[k]:
		if k != i - 1:
			if a[k] != a[k + 1] and b[k] != b[k + 1]:
				cost += 1
				k += 2
			else:
				cost += 1
				k += 1
		else:
			cost += 1
			k += 1
	else:
		k += 1
print(cost)


def lowestCostToEqualize(stringLength, strA, strB):
	(total, i) = (0, 0)
	while i < stringLength:
		if strA[i] != strB[i]:
			total += 1
			try:
				i += strA[i + 1] != strB[i + 1] and strA[i] != strA[i + 1]
			except:
				return total
		i += 1
	return total
print(lowestCostToEqualize(int(input()), input(), input()))


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


n = int(input())
a = input()
a = [a[i] for i in range(n)]
b = input()
b = [b[i] for i in range(n)]
cost = 0
for i in range(n - 1):
	if a[i] != b[i]:
		if a[i] == b[i + 1] and a[i + 1] == b[i]:
			temp = a[i]
			a[i] = a[i + 1]
			a[i + 1] = temp
			cost += 1
		else:
			a[i] = b[i]
			cost += 1
if a[n - 1] != b[n - 1]:
	cost += 1
print(cost)


def solve(n, a, b):
	z = 0
	i = 0
	while i < n:
		if a[i] != b[i]:
			if i + 1 < n and a[i] != b[i] and (a[i] != a[i + 1]):
				i += 2
				z += 1
				continue
			z += 1
		i += 1
	return z

def driver():
	n = int(input())
	a = input()
	b = input()
	print(solve(n, a, b))

def test():
	assert solve(3, '100', '001') == 2
	assert solve(4, '0101', '0011') == 1
driver()


N = int(input())
a = list(input())
b = list(input())
ans = 0
for i in range(N - 1):
	if a[i] != b[i]:
		if a[i + 1] != b[i + 1] and a[i] != a[i + 1]:
			ans += 1
			(a[i], a[i + 1]) = (a[i + 1], a[i])
		else:
			ans += 1
if a[N - 1] != b[N - 1]:
	ans += 1
print(ans)


def lowestCostToEqualize(stringLength, strA, strB):
	if strA[0] == strB[0]:
		(total, hold) = (stringLength - 1, 0)
	else:
		(total, hold) = (stringLength, 1)
	for i in range(1, stringLength):
		if strA[i] == strB[i]:
			total -= 1
		elif hold and strA[i] != strA[i - 1] != strB[i - 1]:
			total -= 1
			hold = 0
		else:
			hold = 1
	return total
print(lowestCostToEqualize(int(input()), input(), input()))


n = int(input())
a = input()
b = input()
c = bin(int(a, base=2) ^ int(b, base=2))[2:].zfill(n)
counts = 0
f = False if c[0] == '0' else True
for i in range(1, n):
	if c[i] == '0' and f:
		counts = counts + 1
		f = False
	elif c[i] == '1' and (not f):
		f = True
	elif c[i] == '1' and f:
		counts = counts + 1
		if a[i] != a[i - 1]:
			f = False
print(counts + (1 if f else 0))


n = int(input())
a = [x for x in input()]
b = [x for x in input()]
ans = 0
for i in range(n):
	if a[i] != b[i]:
		if i < n - 1:
			if a[i] == b[i + 1] and b[i] == a[i + 1]:
				a[i] = b[i]
				a[i + 1] = b[i + 1]
				ans += 1
for i in range(n):
	if a[i] != b[i]:
		ans += 1
print(ans)


nBits = int(input())
bits = input()
target = input()
cost = 0
i = 0
while i < nBits - 1:
	if bits[i] == target[i]:
		i += 1
		continue
	if bits[i + 1] != target[i + 1] and bits[i] != bits[i + 1]:
		i += 2
	else:
		i += 1
	cost += 1
if i == nBits - 1 and bits[nBits - 1] != target[nBits - 1]:
	cost += 1
print(cost)


import sys
input = lambda : sys.stdin.readline().rstrip()
inp = sys.stdin.buffer.readline

def I():
	return list(map(int, inp().split()))
from math import log2
(n,) = I()
a = [int(i) for i in input()]
b = [int(i) for i in input()]
ans = 0
for i in range(n):
	if a[i] != b[i]:
		ans += 1
i = 0
while i < n - 1:
	a1 = [a[i], a[i + 1]]
	b1 = [b[i + 1], b[i]]
	if a1 == [0, 1] or a1 == [1, 0]:
		if b1 == a1:
			ans -= 1
			i += 1
	i += 1
print(ans)


n = int(input())
str_a = input()
str_b = input()
a = []
b = []
for i in range(n):
	a.append(int(str_a[i]))
	b.append(int(str_b[i]))
res = 0
for i in range(n):
	if i < n - 1 and (a[i] == 0 and a[i + 1] == 1 and (b[i] == 1) and (b[i + 1] == 0) or (a[i] == 1 and a[i + 1] == 0 and (b[i] == 0) and (b[i + 1] == 1))):
		(a[i], a[i + 1]) = (b[i], b[i + 1])
		res += 1
	elif a[i] != b[i]:
		a[i] = b[i]
		res += 1
print(res)


import sys
input = sys.stdin.readline

def ceil(x, y):
	return (x + y - 1) // y

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

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

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0):
	hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 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 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

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

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

def union(x, y, link, size):
	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(10000000.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().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
n = int(input())
a = input().strip()
b = input().strip()
ans = 0
i = 0
while i < n:
	if i == n - 1:
		if a[i] != b[i]:
			ans += 1
		i += 1
		continue
	if a[i] == b[i]:
		i += 1
		continue
	if a[i + 1] != b[i + 1]:
		if a[i] != a[i + 1]:
			ans += 1
			i += 2
		else:
			ans += 1
			i += 1
	else:
		ans += 1
		i += 1
print(ans)


from collections import Counter
n = int(input())
a = input()
b = input()
a = list(a)
b = list(b)
ans = 0
for i in range(n - 1):
	if a[i] == b[i]:
		continue
	elif a[i + 1] == b[i + 1]:
		ans += 1
	elif a[i] != a[i + 1]:
		t = a[i]
		a[i] = a[i + 1]
		a[i + 1] = t
		ans += 1
	else:
		ans += 1
if a[n - 1] != b[n - 1]:
	ans += 1
print(ans)


n = int(input())
a = list(map(int, input()))
b = list(map(int, input()))
diff = []
i = 0
ans = 0
while i < n:
	if a[i] != b[i]:
		if i + 1 < n and a[i + 1] != b[i + 1] and (a[i] != a[i + 1]):
			i += 2
		else:
			i += 1
		ans += 1
	else:
		i += 1
print(ans)


n = int(input())
txta = list(input())
txtb = list(input())
preva = txta[0]
prevb = txtb[0]
count = 0
for i in range(1, n):
	cura = txta[i]
	curb = txtb[i]
	if preva != prevb:
		if cura == curb:
			count += 1
			preva = prevb
		elif cura != preva:
			count += 1
			(cura, preva) = (preva, cura)
		else:
			count += 1
			preva = prevb
	else:
		pass
	preva = cura
	prevb = curb
if preva != prevb:
	count += 1
print(count)


n = int(input())
a = input()
b = input()
res = 0
pre = False
for i in range(n):
	if a[i] == b[i]:
		if pre:
			res += 1
			pre = False
	elif not pre:
		pre = True
	elif a[i - 1] == a[i]:
		res += 1
		pre = True
	else:
		res += 1
		pre = False
if pre:
	res += 1
print(res)


n = int(input())
a = input()
b = input()
(ans, now) = (0, 0)
for i in range(n):
	if a[i] == b[i]:
		if now:
			ans += 1
			now = 0
		continue
	elif now:
		if a[i] != a[i - 1]:
			ans += 1
			now = 0
		else:
			ans += 1
	else:
		now = 1
if now:
	ans += 1
print(ans)


n = int(input())
la = input()
lb = input()
i = 0
res = 0
while i < n:
	a = la[i]
	b = lb[i]
	if a == b:
		i += 1
		continue
	if i == n - 1:
		res += 1
		break
	aa = la[i + 1]
	bb = lb[i + 1]
	if aa != bb:
		if a != aa:
			res += 1
			i += 2
			continue
		else:
			res += 1
			i += 1
	else:
		res += 1
		i += 2
print(res)


nBits = int(input())
bits = input()
target = input()
cost = 1 if bits[0] != target[0] else 0
cost1 = 0
cost2 = 0
for i in range(1, len(bits)):
	cost2 = cost1
	cost1 = cost
	if bits[i] != target[i]:
		if bits[i - 1] != target[i - 1] and bits[i] != bits[i - 1]:
			cost = cost2 + 1
		else:
			cost = cost1 + 1
	else:
		cost = cost1
print(cost)


n = int(input())
a = input()
b = input()
p = []
ans = 0
for i in range(n):
	if a[i] != b[i]:
		p.append(i)
for i in range(len(p) - 1):
	if a[p[i]] != a[p[i + 1]] and p[i + 1] - p[i] == 1:
		p[i] = p[i + 1] = -1
		i += 1
		ans += 1
for i in range(len(p)):
	if p[i] != -1:
		ans += 1
print(ans)


n = int(input())
s1 = str(input()) + '00'
s2 = str(input()) + '00'
i = 0
ans = 0
while i != n:
	if s1[i] != s2[i]:
		if s1[i] == s2[i + 1] and s1[i + 1] != s2[i + 1]:
			i += 1
		ans += 1
	i += 1
if n == 1:
	if s1[0] == s2[0]:
		print(0)
	else:
		print(1)
else:
	print(ans)


import sys

def answer(n, a, b):
	cost = 0
	ptr = 0
	while ptr < n - 1:
		if a[ptr] != b[ptr] and a[ptr + 1] != b[ptr + 1] and (a[ptr] == b[ptr + 1]):
			cost += 1
			ptr += 1
		elif a[ptr] != b[ptr]:
			cost += 1
		ptr += 1
	if ptr == n - 1 and a[-1] != b[-1]:
		cost += 1
	return cost

def main():
	n = int(sys.stdin.readline())
	a = sys.stdin.readline().rstrip()
	b = sys.stdin.readline().rstrip()
	print(answer(n, a, b))
	return
main()


n = int(input())
s = input()
t = input()
A = []
for i in range(n):
	if s[i] != t[i]:
		A.append(i + 1)
i = 0
ans = 0
while i < len(A):
	if i != len(A) - 1 and A[i + 1] - A[i] == 1 and (s[A[i] - 1] != s[A[i + 1] - 1]):
		ans += 1
		i += 2
	else:
		ans += 1
		i += 1
print(ans)


def pro(a, b):
	n = len(a)
	lst = [0] * n
	for i in range(n):
		if a[i] != b[i]:
			lst[i] = 1
	i = 0
	ans = 0
	while i < n:
		if lst[i]:
			if i + 1 < n and lst[i + 1] and (a[i] == b[i + 1]) and (a[i + 1] == b[i]):
				ans += 1
				i += 2
				continue
			else:
				ans += 1
		i += 1
	print(ans)
n = int(input())
a = input()
b = input()
pro(a, b)


n = int(input())
ch = input()
ch2 = input()
L3 = [0] * n
for i in range(n):
	if ch[i] != ch2[i]:
		L3[i] = 1
i = 0
while i < n - 1:
	if L3[i] == 1 and L3[i + 1] == 1 and (ch[i] != ch[i + 1]):
		L3[i] = 0
		i += 2
	else:
		i += 1
print(sum(L3))


def lowestCostToEqualize(strA, strB):
	(total, i) = (0, 0)
	while True:
		try:
			if strA[i] != strB[i]:
				total += 1
				i += strA[i + 1] != strB[i + 1] and strA[i] != strA[i + 1]
		except:
			return total
		i += 1
input()
print(lowestCostToEqualize(input(), input()))


n = int(input())
s1 = input()
s2 = input()
pointer = 0
op = 0
while pointer < n:
	if s1[pointer] == s2[pointer]:
		pointer += 1
	elif pointer == n - 1:
		op += 1
		pointer += 1
	elif s1[pointer] == s2[pointer + 1] and s1[pointer + 1] == s2[pointer]:
		op += 1
		pointer += 2
	else:
		op += 1
		pointer += 1
print(op)


size = int(input())
a = input()
b = input()
k = 0
count = 0
while k < size - 1:
	if a[k] == b[k]:
		k += 1
	else:
		count += 1
		if a[k + 1] == b[k] and a[k + 1] != b[k + 1]:
			k += 2
		else:
			k += 1
if k == size - 1 and a[k] != b[k]:
	count += 1
print(count)


from sys import stdin
n = int(stdin.readline())
a = stdin.readline()
b = stdin.readline()
a += '0'
b += '0'
ans = 0
i = 0
while i < n:
	if a[i] != b[i]:
		if a[i] == b[i + 1] and b[i] == a[i + 1]:
			i += 2
			ans += 1
		else:
			i += 1
			ans += 1
	else:
		i += 1
print(ans)


n = int(input())
a = input()
b = input()
s = 0
f = 0
for i in range(n - 1):
	if f == 1:
		f = 0
		continue
	if a[i] != b[i] and a[i] != a[i + 1] and (b[i] != b[i + 1]):
		s += 1
		f = 1
	elif a[i] != b[i]:
		s += 1
if f == 0:
	if a[n - 1] != b[n - 1]:
		s += 1
print(s)


N = int(input())
A = input()
B = input()
ans = 0
n = 0
while n < N:
	if A[n] != B[n]:
		ans += 1
		if n + 1 < N and A[n + 1] == B[n] and (B[n + 1] == A[n]):
			n += 2
		else:
			n += 1
	else:
		n += 1
print(ans)


import sys
(n, s1, s2) = [line.rstrip() for line in sys.stdin]
n = int(n)
i = c = 0
flag = False
while i < n - 1:
	flag = False
	if s1[i] != s2[i]:
		c += 1
		flag = False
		if s1[i] != s1[i + 1]:
			flag = True if i != n - 3 else flag
			i += 1
	i += 1
c += 1 if not flag and s1[n - 1] != s2[n - 1] else 0
print(c)


n = int(input())
a = input()
b = input()
(w, r) = (-1, -1)
res = 0
for (i, x) in enumerate(a):
	if b[i] != x:
		if w == -1:
			(w, r) = (x, i)
		elif w != x:
			if i - r > 1:
				res += 1
				(w, r) = (x, i)
			else:
				(w, r) = (-1, -1)
				res += 1
		else:
			res += 1
			(w, r) = (x, i)
if w != -1:
	res += 1
print(res)


n = int(input())
a = input()
b = input()
cost = 0
difPos = []
for i in range(len(a)):
	if a[i] != b[i]:
		if len(difPos) != 0 and difPos[-1] + 1 == i:
			aux = difPos[-1]
			if a[i] == b[aux] and a[aux] == b[i]:
				del difPos[-1]
				cost += 1
			else:
				difPos.append(i)
		elif len(difPos) != 0 and difPos[-1] + 1 < i:
			difPos.append(i)
		elif len(difPos) == 0:
			difPos.append(i)
cost += len(difPos)
print(cost)


from collections import Counter
n = int(input())
a = input()
b = input()
ca = Counter(a)
cb = Counter(b)
i = 0
ans = 0
while i < n:
	if a[i] != b[i]:
		if i < n - 1 and a[i] == b[i + 1] and (a[i + 1] == b[i]):
			ans += 1
			i += 2
		else:
			ans += 1
			i += 1
	else:
		i += 1
print(ans)


from collections import defaultdict
n = int(input())
x = input()
y = input()
a = [int(i) for i in x]
b = [int(i) for i in y]
d = defaultdict(int)
res = []
for i in range(n):
	if a[i] != b[i]:
		d[i] = a[i]
		res += [i]
i = 1
c = 0
while i < len(res):
	if res[i] - res[i - 1] < 2 and d[res[i]] != d[res[i - 1]]:
		c += 1
		i += 2
	elif i + 1 < len(res) and res[i + 1] - res[i] < 2 and (d[res[i]] != d[res[i + 1]]):
		c += 1
		i += 3
	else:
		i += 1
ln = len(res) - 2 * c
ans = ln + c
print(ans)


def solve(n, a, b):
	(cur_flips, i) = (0, 0)
	while i < n:
		if i + 1 < n:
			if a[i] != b[i] and a[i + 1] != b[i + 1] and (a[i] == b[i + 1]):
				cur_flips += 1
				i += 1
			elif a[i] != b[i]:
				cur_flips += 1
		elif a[i] != b[i]:
			cur_flips += 1
		i += 1
	return cur_flips
n = int(input())
a = input()
b = input()
print(solve(n, a, b))


n = int(input())
c = p = l = 0
for (x, y) in zip(input(), input()):
	if y != x and p == 1:
		if x == l:
			p = 0
		else:
			l = y
			p = 1
		c += 1
	elif y == x:
		if p == 1:
			c += 1
		p = 0
	else:
		p = 1
		l = y
if p == 1:
	c += 1
print(c)


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
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')

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
n = Int()
a = input()
b = input()
need = {}
for i in range(n):
	if a[i] != b[i]:
		need[i] = b[i]
changed = 0
i = 0
while i < n:
	if i in need.keys():
		cur = need[i]
		i += 1
		c = 1
		while i < n and i in need.keys() and (need[i] != cur):
			cur = need[i]
			i += 1
			c += 1
		changed += c - c % 2
	else:
		i += 1
ans = changed // 2
ans += len(need) - changed
print(ans)


import sys
import os
import math
import copy
from math import gcd
from bisect import bisect
from io import BytesIO, IOBase
from math import sqrt, floor, factorial, gcd, log, ceil
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations
from itertools import accumulate

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

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

def Lstr():
	return list(sys.stdin.readline().strip())

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

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

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

def Hash():
	return dict()

def Mod():
	return 1000000007

def Ncr(n, r, p):
	return fact[n] * (ifact[r] * ifact[n - r] % p) % p

def Most_frequent(list):
	return max(set(list), key=list.count)

def Mat2x2(n):
	return [List() for _ in range(n)]

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

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

def btod(n):
	return int(n, 2)

def common(l1, l2):
	return set(l1).intersection(l2)

def solution():
	n = Int()
	a = Str()
	b = Str()
	case1 = 0
	case2 = 0
	i = 0
	while i < n - 1:
		if a[i] != b[i] and a[i + 1] != b[i + 1] and (a[i + 1] != a[i]):
			case1 += 1
			i = i + 2
		else:
			i += 1
	for i in range(n):
		if a[i] != b[i]:
			case2 += 1
	print(case2 - case1)
solution()


n = int(input().strip())
s1 = [int(__) for __ in list(input().strip())]
s2 = [int(__) for __ in list(input().strip())]
ans = 0
for i in range(n):
	if s1[i] != s2[i]:
		if i + 1 < n and s1[i + 1] != s2[i + 1] and (s1[i] != s1[i + 1]):
			ans += 1
			s1[i] = 1 - s1[i]
			s1[i + 1] = 1 - s1[i + 1]
		else:
			ans += 1
			s1[i] = 1 - s1[i]
print(ans)


import math, sys
from collections import defaultdict, Counter, deque
INF = float('inf')
MOD = 1000000007

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def isPrime(n):
	if n <= 1:
		return False
	i = 2
	while i ** 2 <= n:
		if n % i == 0:
			return False
		i += 1
	return True

def primeFactors(n):
	factors = []
	i = 2
	while i ** 2 <= n:
		while n % i == 0:
			factors.append(i)
			n //= i
		i += 1
	if n > 1:
		factors.append(n)
	return factors

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

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

def main():
	n = int(input())
	s1 = list(input())
	s2 = list(input())
	ans = 0
	for i in range(n):
		if s1[i] != s2[i]:
			if i < n - 1 and (s2[i] == s1[i + 1] and s2[i + 1] == s1[i]):
				(s2[i], s2[i + 1]) = (s2[i + 1], s2[i])
			ans += 1
	print(ans)
t = 1
for _ in range(t):
	main()


n = int(input())
a = list(map(int, input()))
b = list(map(int, input()))
ans = 0
for i in range(1, n):
	if a[i - 1] != a[i] and a[i - 1] == b[i] and (a[i] == b[i - 1]):
		(a[i - 1], a[i]) = (a[i], a[i - 1])
		ans += 1
ans += sum(map(lambda o: int(a[o] != b[o]), range(n)))
print(ans)


n = int(input())
(a, b) = (input(), input())
l = len(a)
ans = 0
i = 0
while i <= l - 2:
	if a[i] == b[i]:
		i = i + 1
		continue
	elif a[i + 1] != b[i + 1] and a[i + 1] != a[i]:
		ans = ans + 1
		i = i + 2
	else:
		ans = ans + 1
		i = i + 1
if a[l - 1] != b[l - 1] and i != l:
	ans = ans + 1
print(ans)


n = int(input())
(a, b) = (input(), input())
(i, ans) = (0, 0)
while i < n:
	if a[i] == b[i]:
		i += 1
	elif i + 1 < n:
		if a[i + 1] != b[i + 1]:
			if a[i] != a[i + 1]:
				ans += 1
				i += 2
			else:
				ans += 1
				i += 1
		else:
			ans += 1
			i += 1
	else:
		ans += 1
		i += 1
print(ans)


n = int(input())
s = input()
t = input()
dp = [0] * n
dp[0] = not s[0] == t[0]
for i in range(1, n):
	if s[i] == t[i]:
		dp[i] = dp[i - 1]
	else:
		dp[i] = dp[i - 1] + 1
		if s[i - 1] == t[i] and t[i - 1] == s[i]:
			if i > 1:
				dp[i] = dp[i - 2] + 1
			else:
				dp[i] = 1
print(int(dp[n - 1]))


R = lambda : map(int, input())
input()
(c, p) = (0, 2)
for (x, y) in zip(R(), R()):
	if x ^ y and x != p:
		c += 1
		p = x ^ 1
	else:
		p = 2
print(c)


def solve(A, B):
	N = len(A)
	flag = [False for _ in range(N)]
	op = 0
	ind = 0
	while ind < N - 1:
		if A[ind] != B[ind] and A[ind + 1] != B[ind + 1] and (A[ind] != A[ind + 1]):
			op += 1
			flag[ind] = flag[ind + 1] = True
			ind += 2
		else:
			ind += 1
	for ind in range(N):
		if not flag[ind] and A[ind] != B[ind]:
			op += 1
	return op
N = int(input())
A = input()
B = input()
print(solve(A, B))


n = int(input())
s = input()
s2 = input()
l = [0] * (n + 1)
if s[0] == s2[0]:
	l[0] = 0
else:
	l[0] = 1
for i in range(1, n):
	if s[i] == s2[i]:
		l[i] = l[i - 1]
	else:
		l[i] = l[i - 1] + 1
		if s[i - 1] != s2[i - 1] and s[i - 1] == s2[i]:
			l[i] = min(l[i - 2] + 1, l[i])
print(l[n - 1])


n = int(input())
a = list(str(input()))
b = str(input())
answer = 0
for i in range(n - 1):
	if a[i] != b[i]:
		if a[i + 1] + a[i] == b[i] + b[i + 1]:
			a[i + 1] = b[i + 1]
			a[i] = b[i]
			answer += 1
		else:
			a[i] = b[i]
			answer += 1
if a[-1] != b[-1]:
	answer += 1
print(answer)


n = int(input())
a = input()
b = input()
c = [int(a[i]) ^ int(b[i]) for i in range(n)]
cost = 0
last = 0
for i in range(n - 1):
	last = 0
	if c[i] and c[i + 1] and (a[i] != a[i + 1]):
		cost += 1
		last = 1
		c[i] = c[i + 1] = 0
	else:
		cost += c[i]
if c[-1] and last == 0:
	cost += 1
print(cost)


n = int(input())
x1 = list(input())
x2 = list(input())
ans = 0
if n == 1:
	if x1 == x2:
		print(0)
	else:
		print(1)
else:
	for i in range(n):
		if x1[i] != x2[i]:
			if i != n - 1:
				if x1[i + 1] != x2[i + 1]:
					(x1[i], x1[i + 1]) = (x1[i + 1], x1[i])
				elif x1[i + 1] == x2[i + 1]:
					x1[i] = x2[i]
				ans += 1
			else:
				ans += 1
	print(ans)


n = int(input())
s1 = input()
s2 = input()
count = 0
i = 0
while i <= n - 1:
	if s1[i] == s2[i]:
		i += 1
	elif i + 2 <= n - 1:
		if s1[i + 1] != s2[i + 1]:
			if s1[i] != s1[i + 1]:
				count += 1
				i += 2
			else:
				count += 1
				i += 1
		else:
			count += 1
			i += 1
	elif i + 1 <= n - 1:
		if s1[i + 1] != s2[i + 1]:
			if s1[i] != s1[i + 1]:
				count += 1
				break
			else:
				count += 2
				break
		else:
			count += 1
			break
	else:
		count += 1
		break
print(count)


w = int(input())
a = input()
b = input()
(a, b) = (list(a), list(b))
ans = 0
for i in range(w):
	if a[i] != b[i]:
		if i < w - 1 and a[i] == b[i + 1] and (a[i + 1] == b[i]):
			(b[i], b[i + 1]) = (b[i + 1], b[i])
			ans += 1
		else:
			b[i] = str(abs(int(b[i]) - 1))
			ans += 1
	else:
		pass
print(ans)


import sys
input = sys.stdin.readline
n = int(input())
a = input()
b = input()
s = 0
i = 0
while i != len(a):
	if a[i] != b[i]:
		if a[i + 1] != b[i + 1] and a[i] != a[i + 1]:
			s += 1
			i += 2
		else:
			s += 1
			i += 1
	else:
		i += 1
print(s)


mod = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
n = ii()
s1 = ls()
s2 = ls()
c = 0
for i in range(n - 1):
	if s1[i] + s2[i] == '10' and s1[i + 1] + s2[i + 1] == '01' or (s1[i] + s2[i] == '01' and s1[i + 1] + s2[i + 1] == '10'):
		c += 1
		s1[i] = s2[i]
		s1[i + 1] = s2[i + 1]
	elif s1[i] != s2[i]:
		c += 1
if s1[n - 1] != s2[n - 1]:
	c += 1
print(c)


n = int(input())
s1 = input() + 'xx'
s2 = input() + 'xx'
count = 0
i = 0
while i < n:
	if s2[i] == s1[i]:
		i += 1
		continue
	if s2[i + 1] == s1[i + 1]:
		count += 1
		i += 2
	elif s2[i + 1] != s2[i]:
		count += 1
		i += 2
	elif s2[i + 2] == s1[i + 2]:
		count += 2
		i += 2
	elif s2[i + 2] == s2[i + 1]:
		count += 2
		i += 2
	else:
		count += 2
		i += 3
print(count)


n = int(input())
a = list(input())
b = list(input())
comp = []
cost = 0
for i in range(n):
	if i == n - 1:
		if a[i] != b[i]:
			cost += 1
	elif a[i] != b[i]:
		if a[i + 1] != b[i + 1] and a[i] != a[i + 1]:
			cost += 1
			a[i + 1] = b[i + 1]
		else:
			cost += 1
print(cost)


n = int(input())
s1 = input()
s1 = list(s1)
s2 = input()
s2 = list(s2)
count1s = 0
idx = -10
mincost = 0
i = 0
while i < n:
	if i < n - 1 and (s1[i] == '1' and s2[i] == '0' and (s1[i + 1] == '0') and (s2[i + 1] == '1') or (s1[i] == '0' and s2[i] == '1' and (s1[i + 1] == '1') and (s2[i + 1] == '0'))):
		mincost += 1
		i += 2
	elif s1[i] != s2[i]:
		mincost += 1
		i += 1
	else:
		i += 1
print(mincost)


n = int(input())
a = [c for c in input()]
b = [c for c in input()]
total = 0
for x in range(n - 1):
	if a[x] != b[x]:
		if a[x + 1] != b[x + 1] and a[x] != a[x + 1]:
			a[x + 1] = b[x + 1]
		total += 1
if a[n - 1] != b[n - 1]:
	total += 1
print(total)


import heapq
n = int(input())
a = input()
b = input()
a = list(a)
b = list(b)
h = []
c = 0
for i in range(n - 1):
	if a[i] != b[i]:
		if a[i + 1] != b[i + 1] and a[i + 1] != a[i]:
			(a[i], a[i + 1]) = (a[i + 1], a[i])
			c += 1
		else:
			c += 1
			a[i] = b[i]
if a[n - 1] != b[n - 1]:
	c += 1
print(c)


import string
import math
import collections

def main():
	n = int(input())
	s1 = input()
	s2 = input()
	inc = 0
	x = 0
	while x < n:
		if s1[x] != s2[x]:
			if x + 1 == n:
				inc += 1
				x += 1
				continue
			elif s1[x + 1] == s2[x + 1]:
				inc += 1
				x += 1
				continue
			elif s1[x + 1] != s2[x + 1] and s1[x] == s2[x + 1] and (s1[x + 1] == s2[x]):
				inc += 1
				x += 2
			else:
				inc += 1
				x += 1
		else:
			x += 1
	print(inc)
main()


lenght = int(input())
a = input() + '00'
b = input() + '00'
counter = 0
i = 0
while i < lenght:
	if a[i] == b[i]:
		i = i + 1
	elif a[i] == b[i + 1] and a[i + 1] == b[i]:
		counter = counter + 1
		i = i + 2
	else:
		counter = counter + 1
		i = i + 1
print(counter)


def calculate():
	n = int(input())
	a = list(input())
	b = list(input())
	if a == b:
		print(0)
		exit()
	cost = 0
	for i in range(n):
		if a[i] == b[i]:
			continue
		if i == n - 1:
			cost += 1
			continue
		if a[i] == '1' and a[i + 1] == '0':
			if a[i + 1] == b[i + 1] and b[i + 1] == '0':
				cost += 1
				a[i] = '0'
			else:
				cost += 1
				a[i] = '0'
				a[i + 1] = '1'
		elif a[i] == '0' and a[i + 1] == '1':
			if a[i + 1] == b[i + 1] and b[i + 1] == '1':
				cost += 1
				a[i] = '1'
			else:
				cost += 1
				a[i] = '1'
				a[i + 1] = '0'
		else:
			cost += 1
			if a[i] == '1':
				a[i] = '0'
			else:
				a[i] = '1'
	return cost
ans = calculate()
print(ans)


def solve(n, a, b):
	(flips, i) = (0, 0)
	while i < n:
		if a[i] != b[i]:
			if i + 1 < n and a[i + 1] != b[i + 1] and (a[i] == b[i + 1]):
				i += 1
			flips += 1
			i += 1
		else:
			i += 1
	return flips
n = int(input())
a = input()
b = input()
print(solve(n, a, b))


n = int(input().strip())
a = input().strip()
b = input().strip()
a = [x for x in a]
b = [x for x in b]
sum = 0
li = []
dict = {}
for k in range(n):
	if a[k] != b[k]:
		li.append(k)
		dict[k] = int(a[k])
if len(li) == 0:
	print(0)
elif len(li) == 1:
	print(1)
else:
	sum = 0
	int
	k = 0
	while k < len(li) - 1:
		if dict[li[k]] != dict[li[k + 1]]:
			if li[k + 1] - li[k] > 1:
				sum = sum + 1
				k = k + 1
			else:
				sum = sum + 1
				k = k + 2
		else:
			sum = sum + 1
			k = k + 1
	if k == len(li) - 1:
		sum = sum + 1
	print(sum)


n = input()
n = int(n)
c = input()
d = input()
e = 0
p = -1
m = '0'
for i in range(n):
	if c[i] != d[i]:
		if p == -1:
			e += 1
			p = i
			m = c[i]
		elif i - p >= 2 or m == c[i]:
			e += 1
			p = i
			m = c[i]
		else:
			e += 0
			p = -1
			m = '0'
print(e)


lenght = int(input())
string1 = input()
string2 = input()
flip = [False] * lenght
cost = 0
for i in range(0, lenght):
	if string1[i] != string2[i]:
		flip[i] = True
		cost += 1
for i in range(0, lenght - 1):
	if flip[i] and flip[i + 1] and (string1[i] != string1[i + 1]):
		flip[i] = False
		flip[i + 1] = False
		cost -= 1
print(cost)


n = int(input())
s = input()
s1 = input()
s = list(s)
s1 = list(s1)
c = 0
for i in range(0, n):
	if s[i] != s1[i]:
		if i < n - 1:
			if s[i + 1] != s1[i + 1] and s1[i + 1] == s[i] and (s1[i] == s[i + 1]):
				c = c + 1
				temp = s[i]
				s[i] = s[i + 1]
				s[i + 1] = temp
			else:
				c = c + 1
		else:
			c = c + 1
print(c)


import math
n = int(input())
a = input()
b = input()
f = 0
f1 = 0
l = 0
l2 = 100000
c = 0
for i in range(n):
	if a[i] == b[i]:
		continue
	else:
		l2 = i
		if f == 0:
			if a[i] == '1':
				f1 = 1
			else:
				f1 = 0
			f = 1
			l = i
		elif i - l == 1:
			if f1 == 1 and a[i] == '0' or (f1 == 0 and a[i] == '1'):
				c += 1
				f = 0
				l2 = 100000
			else:
				c += 1
				if a[i] == '1':
					f1 = 1
				else:
					f1 = 0
				l = i
		else:
			c += 1
			if a[i] == '1':
				f1 = 1
			else:
				f1 = 0
			l = i
if l2 != 100000:
	print(c + 1)
else:
	print(c)


import os.path
from math import gcd, floor, ceil
from collections import *
import sys
mod = 1000000007
INF = float('inf')

def st():
	return list(sys.stdin.readline().strip())

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

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

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

def pr(n):
	return sys.stdout.write(str(n) + '\n')

def prl(n):
	return sys.stdout.write(str(n) + ' ')
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def solve():
	n = inp()
	a = input()
	b = input()
	ans = 0
	i = 0
	while i < n:
		if a[i] == b[i]:
			i += 1
		elif i + 1 < n:
			if a[i] != b[i] and a[i + 1] != b[i + 1] and (a[i] != a[i + 1]):
				ans += 1
				i += 2
			else:
				ans += 1
				i += 1
		elif a[i] != b[i]:
			ans += 1
			i += 1
	pr(ans)
for _ in range(1):
	solve()


n = int(input())
a = input().strip()
b = input().strip()
ans = i = 0
while i < n:
	if a[i] != b[i]:
		if i + 1 < n and a[i + 1] != b[i + 1] and (a[i] != a[i + 1]):
			i += 1
		ans += 1
	i += 1
print(ans)


n = int(input())
ch = input()
L = []
for i in ch:
	L.append(int(i))
ch = input()
L2 = []
for i in ch:
	L2.append(int(i))
L3 = [0] * n
for i in range(n):
	if L[i] != L2[i]:
		L3[i] = 1
i = 0
while i < n - 1:
	if L3[i] == 1 and L3[i + 1] == 1 and (L[i] != L[i + 1]):
		L3[i] = 0
		i += 2
	else:
		i += 1
print(sum(L3))


import sys
input = sys.stdin.readline

def main():
	n = int(input())
	a = input().strip()
	b = input().strip()
	res = 0
	i = 0
	while i < n:
		if a[i] != b[i]:
			if i < n - 1 and a[i + 1] != b[i + 1] and (a[i] != a[i + 1]):
				res += 1
				i += 2
			else:
				res += 1
				i += 1
		else:
			i += 1
	print(res)
main()


n = int(input())
a = input()
b = input()
price = 0
prev = 0
for i in range(n):
	if a[i] != b[i]:
		if prev == 1 and a[i] != a[i - 1]:
			prev = 0
		else:
			price += 1
			prev = 1
	else:
		prev = 0
print(price)


from collections import Counter
import string
import bisect
import random
import math
import sys
from fractions import Fraction

def array_int():
	return [int(i) for i in sys.stdin.readline().split()]

def vary(arrber_of_variables):
	if arrber_of_variables == 1:
		return int(sys.stdin.readline())
	if arrber_of_variables >= 2:
		return map(int, sys.stdin.readline().split())

def makedict(var):
	return dict(Counter(var))
testcases = 1
for _ in range(testcases):
	n = vary(1)
	a = input()
	b = input()
	i = 0
	ans = 0
	while i < n:
		if a[i] != b[i]:
			if i + 1 < n:
				if a[i + 1] != b[i + 1] and a[i] != a[i + 1]:
					ans += 1
					i += 2
				else:
					ans += 1
					i += 1
			else:
				ans += 1
				i += 1
		else:
			i += 1
	print(ans)


input()
a = list(input())
b = list(input())
cnt = 0
for i in range(len(a) - 1):
	if a[i] != b[i]:
		if a[i] == b[i + 1] and a[i + 1] == b[i]:
			a[i] = b[i]
			a[i + 1] = b[i + 1]
			cnt += 1
		else:
			a[i] = b[i]
			cnt += 1
if a[-1] != b[-1]:
	cnt += 1
print(cnt)


n = int(input())
a = input()
b = input()
dp = [0] * n
p0 = p1 = -1
for i in range(n):
	if a[i] == '1' and b[i] == '0':
		if p0 == -1:
			dp[i] = 1 if i == 0 else dp[i - 1] + 1
		else:
			dp[i] = min(dp[i - 1] + 1, (dp[p0 - 1] if p0 > 0 else 0) + abs(i - p0))
		p1 = i
	elif a[i] == '0' and b[i] == '1':
		if p1 == -1:
			dp[i] = 1 if i == 0 else dp[i - 1] + 1
		else:
			dp[i] = min(dp[i - 1] + 1, (dp[p1 - 1] if p1 > 0 else 0) + abs(i - p1))
		p0 = i
	else:
		dp[i] = dp[i - 1]
print(dp[-1])


n = int(input())
a = input()
b = input()
i = 0
ans = 0
t = False
while i < n - 1:
	if a[i] == b[i]:
		i += 1
	elif a[i] == a[i + 1] and b[i] == b[i + 1]:
		i += 1
		ans += 1
	else:
		if i == n - 2:
			t = True
		ans += 1
		i += 2
if t == True:
	print(ans)
elif a[-1] == b[-1]:
	print(ans)
else:
	print(ans + 1)


n = int(input())
a = [i for i in input()]
b = [i for i in input()]
a.append(b[-1])
b.append(b[-1])
ans = 0
for i in range(n):
	if a[i] != b[i] and a[i + 1] != b[i + 1] and (a[i] != a[i + 1]):
		ans += 1
		a[i + 1] = b[i + 1]
	elif a[i] != b[i]:
		ans += 1
print(ans)


n = int(input())
a = list(str(input()))
b = list(str(input()))
c = 0
i = 0
while i < n - 1:
	if a[i] != b[i]:
		if a[i] == b[i + 1] and a[i + 1] == b[i]:
			c += 1
			(a[i], a[i + 1]) = (a[i + 1], a[i])
			i += 2
		else:
			a[i] = b[i]
			i += 1
			c += 1
	else:
		i += 1
if a[n - 1] != b[n - 1]:
	c += 1
print(c)


from os import path
import sys, time
from math import ceil, floor, gcd, log, log2, factorial
from collections import *
maxx = float('inf')
I = lambda : int(sys.stdin.buffer.readline())
tup = lambda : map(int, sys.stdin.buffer.readline().split())
lint = lambda : [int(x) for x in sys.stdin.buffer.readline().split()]
S = lambda : sys.stdin.readline().replace('\n', '').strip()

def grid(r, c):
	return [lint() for i in range(r)]
stpr = lambda x: sys.stdout.write(f'{x}' + '\n')
star = lambda x: print(' '.join(map(str, x)))
localsys = 0
start_time = time.time()
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
n = I()
a = S()
b = S()
(ans, i) = (0, 0)
while i < n:
	if i < n - 1 and a[i] != b[i] and (a[i + 1] != b[i + 1]) and (a[i] != a[i + 1]):
		ans += 1
		i += 1
	elif a[i] != b[i]:
		ans += 1
	i += 1
print(ans)
if localsys:
	print('\n\nTime Elased :', time.time() - start_time, 'seconds')


n = int(input())
a = input().strip()
b = input().strip()
c = []
for i in range(n):
	if a[i] != b[i]:
		c.append(1)
	else:
		c.append(0)
for i in range(1, n):
	if c[i] == c[i - 1] == 1 and a[i] != a[i - 1]:
		c[i] = 0
print(c.count(1))


input()
a = input()
b = input()
total = 0
for i in range(len(a)):
	if a[i] != b[i]:
		total += 1
i = 0
while i < len(a) - 1:
	if a[i] != b[i] and a[i] != a[i + 1] and (b[i] != b[i + 1]):
		total -= 1
		i += 1
	i += 1
print(total)


a = int(input())
b = input() + '@'
c = input() + '@'
(i, s) = (0, 0)
while i < a:
	if b[i] != c[i]:
		if b[i + 1] != c[i + 1] and b[i] != b[i + 1]:
			s += 1
			i += 1
		else:
			s += 1
	i += 1
print(s)


import sys
from sys import stdin

def solve(n, a, b):
	cost = 0
	i = 0
	while i < n:
		if i < n - 1:
			if a[i] != b[i]:
				if a[i + 1] != a[i] and a[i + 1] != b[i + 1]:
					(a[i], a[i + 1]) = (a[i + 1], a[i])
					cost += 1
					i += 2
				else:
					a[i] = a[i] ^ 1
					cost += 1
					i += 1
			else:
				i += 1
		else:
			if a[i] != b[i]:
				cost += 1
				a[i] ^= 1
			i += 1
	return cost
n = int(input())
a = list(map(int, list(input())))
b = list(map(int, list(input())))
print(solve(n, a, b))


n = int(input())
a = list(input())
b = list(input())
i = 0
num = 0
while i < n:
	if i == n - 1:
		if a[i] == b[i]:
			i += 1
		else:
			num += 1
			i += 1
	elif a[i] == b[i]:
		i += 1
	elif a[i] == '1' and a[i + 1] == '0' and (b[i] == '0') and (b[i + 1] == '1'):
		num += 1
		i += 2
	elif a[i] == '0' and a[i + 1] == '1' and (b[i] == '1') and (b[i + 1] == '0'):
		num += 1
		i += 2
	elif a[i] != b[i]:
		num += 1
		i += 1
print(num)


import sys
n = int(sys.stdin.readline().strip())
a = sys.stdin.readline().strip()
b = sys.stdin.readline().strip()
i = 0
j = len(a)
acc = 0
while True:
	if j == i:
		break
	if j - i == 1:
		acc = acc + 1 if not a[i] == b[i] else acc
		break
	if a[i] == b[i]:
		i = i + 1
		continue
	if a[i + 1] != b[i + 1] and a[i + 1] != a[i]:
		acc += 1
		i += 2
		continue
	acc += 1
	i += 1
sys.stdout.write(str(acc) + '\n')


n = int(input())
a = input()
b = input()
cost = 0
i = 0
f = False
last_symbol = ''
while i < n:
	if a[i] != b[i]:
		if f and a[i] != last_symbol:
			f = False
		else:
			cost += 1
			f = True
			last_symbol = a[i]
	else:
		f = False
	i += 1
print(cost)


n = int(input())
k1 = input()
k2 = input()
la1 = []
la2 = []
i = 0
count = 0
while i < n:
	if k1[i] != k2[i]:
		if i + 1 < n:
			if k1[i + 1] != k2[i + 1] and k1[i] != k1[i + 1]:
				count += 1
				i += 2
			else:
				count += 1
				i += 1
		else:
			count += 1
			i += 1
	else:
		i += 1
print(count)


import os
import sys
from io import BytesIO, IOBase

def main():
	pass
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 = list(input()) + [0]
t = list(input()) + [0]
c = 0
if s == t:
	print(0)
else:
	for i in range(n):
		if s[i] != t[i]:
			if s[i] == t[i + 1] and s[i + 1] == t[i] and (s[i + 1] != t[i + 1]):
				c = c + 1
				(s[i], s[i + 1]) = (t[i], t[i + 1])
			else:
				c += 1
				s[i] = t[i]
	print(c)


import sys
import bisect
from collections import Counter
read_int = lambda : int(sys.stdin.readline())
read_ints = lambda : map(int, sys.stdin.readline().split())
read_int_list = lambda : list(read_ints())
read = lambda : sys.stdin.readline().strip()
read_list = lambda : sys.stdin.readline().split()

def main():
	n = read_int()
	a = list(read())
	ori = a
	b = list(read())
	c = 0
	for i in range(n):
		if a[i:i + 2] == b[i:i + 2][::-1] and a[i:i + 2] in [list('01'), list('10')]:
			(a[i], a[i + 1]) = (a[i + 1], a[i])
			c += 1
		elif a[i] != b[i]:
			c += 1
	print(c)
main()


n = int(input())
a = list(input())
b = list(input())
dp = []
sm1 = 0
sm2 = 0
for i in range(n - 1):
	if a[i] != b[i]:
		if a[i] != a[i + 1] and a[i + 1] != b[i + 1]:
			sm1 += abs(i - i + 1)
			(a[i], a[i + 1]) = (a[i + 1], a[i])
		else:
			continue
	else:
		continue
for i in range(n):
	if a[i] != b[i]:
		sm2 += 1
print(sm1 + sm2)


def lowestCostToEqualize(stringLength, strA, strB):
	(total, i) = (0, 0)
	while i < stringLength:
		if strA[i] != strB[i]:
			total += 1
			if i != stringLength - 1 and strA[i + 1] != strB[i + 1] and (strA[i] != strA[i + 1]):
				i += 2
				continue
		i += 1
	return total
print(lowestCostToEqualize(int(input()), input(), input()))


from sys import stdin, stdout
from math import gcd, ceil, sqrt
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
(n, a, b) = (ii1(), list(is1()), is1())
res = 0
for i in range(n):
	if a[i] != b[i]:
		if i + 1 < n and a[i + 1] != a[i] and (a[i + 1] != b[i + 1]):
			a[i + 1] = b[i + 1]
			res += 1
		else:
			res += 1
print(res)


from sys import stdin, stdout

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

def INL():
	return [int(_) for _ in stdin.readline().split()]

def INS():
	return stdin.readline()

def OPS(ans):
	stdout.write(str(ans) + '\n')

def OPL(ans):
	[stdout.write(str(_) + ' ') for _ in ans]
	stdout.write('\n')
n = INI()
A = INS()
B = INS()
ans = 0
_ = 0
while _ < n - 1:
	if A[_] != B[_]:
		if A[_ + 1] != B[_ + 1] and int(A[_]) ^ int(A[_ + 1]):
			_ += 1
		ans += 1
	_ += 1
if _ != n:
	ans += int(int(A[_]) ^ int(B[_]))
OPS(ans)


def equalise(s1, s2):
	c = 0
	i = 0
	while i < len(s1):
		if s1[i] != s2[i]:
			if i + 1 < len(s1) and s1[i + 1] != s2[i + 1] and (s1[i] != s1[i + 1]):
				c += 1
				i += 2
			else:
				c += 1
				i += 1
		else:
			i += 1
	return c
n = int(input())
s1 = input()
s2 = input()
print(equalise(s1, s2))


n = int(input().strip())
s = list(map(int, list(input())))
t = list(map(int, list(input())))
c = 0
for i in range(n - 1):
	if s[i] ^ t[i]:
		if s[i + 1] ^ t[i + 1] and s[i] ^ s[i + 1]:
			(s[i], s[i + 1]) = (s[i + 1], s[i])
			c += 1
for (i, j) in zip(s, t):
	if i != j:
		c += 1
print(c)


input()
str1 = input()
str2 = input()
cnt = 0
lastDiff = -1
for i in range(len(str1)):
	if str1[i] != str2[i]:
		if lastDiff == -1:
			lastDiff = i
		elif lastDiff != -1 and str1[lastDiff] != str1[i] and (lastDiff + 1 == i):
			cnt += 1
			lastDiff = -1
		else:
			cnt += 1
			lastDiff = i
if lastDiff != -1:
	cnt += 1
print(cnt)


n = int(input())
a = list(input())
b = list(input())
total = 0
i = 0
while i < n:
	if a[i] != b[i]:
		if i < n - 1 and a[i + 1] != b[i + 1] and (a[i] == b[i + 1]):
			i += 1
			total += 1
		else:
			total += 1
	i += 1
print(total)


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


n = int(input())
lis1 = list(input())
lis2 = list(input())
ans = 0
for i in range(n - 1):
	if not lis1[i] == lis2[i]:
		if lis1[i] == '0' and lis1[i + 1] == '0':
			ans += 1
			lis1[i] = '1'
		elif lis1[i] == '0' and lis1[i + 1] == '1':
			if lis2[i + 1] == '0':
				lis1[i + 1] = '0'
				lis1[i] = '1'
				ans += 1
			else:
				ans += 1
				lis1[i] = '1'
		elif lis1[i] == '1' and lis1[i + 1] == '0':
			if lis2[i + 1] == '1':
				ans += 1
				lis1[i + 1] = '1'
				lis1[i] = '0'
			else:
				ans += 1
				lis1[i] = '0'
		elif lis1[i] == '1' and lis1[i + 1] == '1':
			ans += 1
			lis1[i] = '0'
if not lis1[-1] == lis2[-1]:
	ans += 1
print(ans)


n = int(input())
b1 = input()
b2 = input()
custo = 0
i = 0
while i < n:
	if b1[i] != b2[i]:
		if i < n - 1:
			if b1[i + 1] != b2[i + 1] and b1[i] != b1[i + 1]:
				i += 1
				custo += 1
			else:
				custo += 1
		else:
			custo += 1
	i += 1
print(custo)


for _ in range(1):
	n = int(input())
	s1 = input()
	s2 = input()
	i = 0
	c = 0
	while i < n:
		if s1[i] == s2[i]:
			i += 1
			continue
		elif i + 1 < n and s1[i + 1] != s2[i + 1] and (s1[i] != s1[i + 1]):
			c += 1
			i += 2
		elif i == n - 1:
			c += 1
			break
		else:
			c += 1
			i += 1
	print(c)


n = int(input())
s1 = input()
s2 = input()
ans = 0
i = 0
done = False
while i < n - 1:
	if s1[i] != s2[i]:
		if s1[i + 1] == s2[i + 1]:
			ans += 1
		elif s1[i] != s1[i + 1]:
			if i == n - 2:
				done = True
			ans += 1
			i += 1
		else:
			ans += 1
	i += 1
if s1[n - 1] != s2[n - 1]:
	if not done:
		ans += 1
print(ans)


n = int(input())
a = input()
b = input()
d = 0
idx = []
for i in range(n):
	if a[i] != b[i]:
		if i > 0 and idx and (i - 1 == idx[-1]) and (a[i] != a[i - 1]):
			_ = idx.pop()
			d += 1
		else:
			idx.append(i)
print(d + len(idx))


import sys
import bisect
from collections import Counter, defaultdict as dd

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

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

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

def strl():
	return list(strsp())

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

def strsp():
	return map(str, data().split())
n = int(data())
a = data()
b = data()
c = [0] * n
for i in range(n):
	if a[i] != b[i]:
		c[i] = 1
d = 0
g = sum(c)
for i in range(n - 1):
	if c[i] == 1 and c[i + 1] == 1:
		if a[i] == '0' and a[i + 1] == '1' or (a[i] == '1' and a[i + 1] == '0'):
			d += 1
			c[i] = 0
			c[i + 1] = 0
d += sum(c)
print(min(g, d))


from sys import stdin
input = lambda : stdin.readline()
from math import ceil, sqrt, gcd, factorial
n = int(input())
a = list(input().strip())
b = list(input().strip())
l = [0 for i in range(n)]
for i in range(n):
	if a[i] != b[i]:
		if a[i] == '0':
			l[i] = 2
		else:
			l[i] = 1
count = 0
for i in range(1, n):
	if l[i] == 1:
		if l[i - 1] == 2:
			count += 1
			l[i] = 0
			l[i - 1] = 0
		elif i + 1 < n and l[i + 1] == 2:
			count += 1
			l[i] = 0
			l[i + 1] = 0
	elif l[i] == 2:
		if l[i - 1] == 1:
			count += 1
			l[i] = 0
			l[i - 1] = 0
		elif i + 1 < n and l[i + 1] == 1:
			count += 1
			l[i] = 0
			l[i + 1] = 0
for i in range(n):
	if l[i] > 0:
		count += 1
print(count)


def main():
	n = int(input())
	a = str(input())
	b = str(input())
	i = 0
	c = 0
	while i < n:
		if a[i] == b[i]:
			i = i + 1
			continue
		if i < n - 1 and a[i + 1] != b[i + 1] and (a[i] != a[i + 1]):
			i += 2
			c += 1
			continue
		else:
			c += 1
			i += 1
	return c
print(main())


n = int(input())
s1 = input().strip()
s2 = input().strip()
i = 0
c = 0
while i < len(s1) - 1:
	if s1[i] != s2[i]:
		if s1[i] == s2[i + 1] and s1[i + 1] == s2[i]:
			i += 1
		c += 1
	i += 1
if i < len(s1) and s1[i] != s2[i]:
	c += 1
print(c)


def dp013_equalize(n, a, b):
	a = list(a)
	a.insert(0, 0)
	b = list(b)
	b.insert(0, 0)
	dp = [0]
	if a[1] == b[1]:
		dp.append(0)
	else:
		dp.append(1)
	for i in range(2, n + 1):
		dp.append(dp[i - 1])
		if a[i] != b[i]:
			if a[i - 1] == b[i - 1]:
				dp[i] = dp[i - 1] + 1
			elif a[i - 1] != a[i]:
				dp[i] = dp[i - 2] + 1
			else:
				dp[i] = dp[i - 1] + 1
	return dp[n]
n = int(input())
a = input()
b = input()
print(dp013_equalize(n, a, b))


n = int(input())
(a, b) = (input(), input())
ones = []
zeros = set()
for i in range(n):
	if a[i] != b[i]:
		if a[i] == '1':
			ones.append(i)
		else:
			zeros.add(i)
ones.sort()
ans = 0
for ind1 in ones:
	if ind1 - 1 in zeros:
		zeros.remove(ind1 - 1)
	elif ind1 + 1 in zeros:
		zeros.remove(ind1 + 1)
	ans += 1
ans += len(zeros)
print(ans)


def solve(a, b, n):
	(change, i) = (0, 0)
	while i < n:
		if a[i] != b[i]:
			if i < n - 1 and a[i + 1] != b[i + 1] and (a[i] != a[i + 1]):
				change += 1
				i += 2
			else:
				change += 1
				i += 1
		else:
			i += 1
	return change
n = int(input().strip())
a = list(input().strip())
b = list(input().strip())
print(solve(a, b, n))


n = int(input())
a = input()
b = input()
a_index = []
b_index = []
for i in range(0, len(a)):
	if a[i] == '0' and b[i] != '0':
		a_index.append(i)
	if b[i] == '0' and a[i] != '0':
		b_index.append(i)
cur_a = 0
cur_b = 0
op = 0
same = 0
while cur_a < len(a_index) and cur_b < len(b_index):
	if abs(a_index[cur_a] - b_index[cur_b]) == 1:
		op += 1
		cur_a += 1
		cur_b += 1
		same += 1
	elif a_index[cur_a] > b_index[cur_b]:
		cur_b += 1
	else:
		cur_a += 1
op = op + len(a_index) + len(b_index) - same * 2
print(op)


n = int(input())
a = input()
b = input()
A = list(a)
cost = 0
for i in range(n):
	if a[i] == b[i]:
		A[i] = 'A'
for i in range(n - 1):
	if A[i] != 'A' and A[i + 1] != 'A':
		if A[i] != A[i + 1]:
			(A[i], A[i + 1]) = ('A', 'A')
			cost += 1
for i in A:
	if i != 'A':
		cost += 1
print(cost)


n = int(input())
a = input()
b = input()
i = 0
cost = 0
while i < n:
	if i + 1 < n and (a[i:i + 2] == '01' and b[i:i + 2] == '10') or (a[i:i + 2] == '10' and b[i:i + 2] == '01'):
		cost += 1
		i += 1
	elif a[i] != b[i]:
		cost += 1
	i += 1
print(cost)


s = int(input())
d = input()
f = input()
s1 = 0
f1 = 0
c = 0
for i in range(s):
	if f1 == 1:
		f1 = 0
		continue
	s1 = int(d[i]) - int(f[i])
	if s1 != 0:
		if i < s - 1 and s1 + (int(d[i + 1]) - int(f[i + 1])) == 0:
			i += 1
			c += 1
			f1 = 1
			continue
		else:
			c += 1
print(c)