Rudolf is on his way to the castle. Before getting into the castle, the security staff asked him a question:

Given two binary numbers $a$ and $b$ of length $n$. How many different ways of swapping two digits in $a$ (only in $a$, not $b$) so that bitwise OR of these two numbers will be changed? In other words, let $c$ be the bitwise OR of $a$ and $b$, you need to find the number of ways of swapping two bits in $a$ so that bitwise OR will not be equal to $c$.

Note that binary numbers can contain leading zeros so that length of each number is exactly $n$.

Bitwise OR is a binary operation. A result is a binary number which contains a one in each digit if there is a one in at least one of the two numbers. For example, $01010_2$ OR $10011_2$ = $11011_2$.

Well, to your surprise, you are not Rudolf, and you don't need to help him$\ldots$ You are the security staff! Please find the number of ways of swapping two bits in $a$ so that bitwise OR will be changed.


-----Input-----

The first line contains one integer $n$ ($2\leq n\leq 10^5$) — the number of bits in each number.

The second line contains a binary number $a$ of length $n$.

The third line contains a binary number $b$ of length $n$.


-----Output-----

Print the number of ways to swap two bits in $a$ so that bitwise OR will be changed.


-----Examples-----
Input
5
01011
11001

Output
4

Input
6
011000
010011

Output
6



-----Note-----

In the first sample, you can swap bits that have indexes $(1, 4)$, $(2, 3)$, $(3, 4)$, and $(3, 5)$.

In the second example, you can swap bits that have indexes $(1, 2)$, $(1, 3)$, $(2, 4)$, $(3, 4)$, $(3, 5)$, and $(3, 6)$.

Difficulty: EASY
Tags: Mathematics

Implementation

Starter code:

Solutions:
n = int(input())
a = input()
b = input()
innerZeroes = 0
outerZeroes = 0
ans = 0
for x in range(n):
	if a[x] == '0':
		if b[x] == '0':
			innerZeroes += 1
		outerZeroes += 1
for x in range(n):
	if a[x] == '1':
		if b[x] == '0':
			ans += outerZeroes
		else:
			ans += innerZeroes
print(ans)


n = int(input())
s = input()
r = input()
l = 0
z = 0
for i in range(len(s)):
	if s[i] == '1' and r[i] == '0':
		l += 1
	if s[i] == '0' and r[i] == '0':
		z += 1
print(z * s.count('1') + (s.count('0') - z) * l)


n = int(input())
a = list(map(int, list(input())))
b = list(map(int, list(input())))
A0 = []
A1 = []
CH0 = []
CH1 = []
for i in range(n):
	if a[i] == 0:
		if b[i] == 0:
			CH0.append(i)
		else:
			A0.append(i)
	elif b[i] == 0:
		CH1.append(i)
	else:
		A1.append(i)
ans = len(CH0) * len(A1) + len(CH1) * len(A0) + len(CH0) * len(CH1)
print(ans)


input()
a = input()
b = input()
if '0' not in a or '1' not in a or '0' not in b:
	print(0)
else:
	(o, z, res) = (0, 0, 0)
	for i in a:
		if i == '0':
			z += 1
		else:
			o += 1
	for i in range(0, len(b)):
		if b[i] == '0':
			if a[i] == '0':
				res += o
				z -= 1
			else:
				res += z
				o -= 1
	print(res)


n = int(input())
a = input()
b = input()
c = 0
d = 0
e = 0
f = 0
s = 0
g = []
for i in range(n):
	if a[i] == '0':
		c = c + 1
	else:
		d = d + 1
	if b[i] == '0':
		if a[i] == '0':
			e = e + 1
		g.append(a[i])
for j in range(len(g)):
	if g[j] == '0':
		s = s + d
	else:
		s = s + c - e
print(s)


n = int(input())
r = input()
r1 = input()
ans1 = 0
ans0 = 0
c1 = 0
c0 = 0
for i in range(n):
	if r1[i] == '0':
		if r[i] == '0':
			c0 = c0 + 1
		else:
			c1 = c1 + 1
	elif r[i] == '0':
		ans0 = ans0 + 1
	else:
		ans1 = ans1 + 1
fans = c0 * ans1 + c1 * ans0 + c0 * c1
print(fans)


n = int(input())
a = input()
b = input()
x = [0] * 4
for (i, j) in zip(a, b):
	x[2 * int(i) + int(j)] += 1
print(x[0] * x[2] + x[0] * x[3] + x[1] * x[2])


n = int(input())
s1 = input()
s2 = input()
l1 = []
c1 = 0
c2 = 0
c3 = 0
c4 = 0
c5 = 0
for i in range(n):
	l1.append([s1[i], s2[i]])
for i in range(len(l1)):
	if l1[i] == ['0', '0']:
		c1 = c1 + 1
	elif l1[i] == ['1', '1']:
		c2 = c2 + 1
	elif l1[i] == ['1', '0']:
		c3 = c3 + 1
	elif l1[i] == ['0', '1']:
		c4 = c4 + 1
print(c1 * (c2 + c3) + c3 * c4)


n = int(input())
a1 = input()
a2 = input()
z = 0
o = 0
m1 = 0
m2 = 0
for i in range(n):
	if a1[i] == a2[i] and a1[i] == '0':
		z += 1
	elif a1[i] == a2[i] and a1[i] == '1':
		o += 1
	elif a2[i] == '1' and a1[i] == '0':
		m1 += 1
	else:
		m2 += 1
print(z * (o + m2) + m1 * m2)


n = int(input())
a = input()
b = input()
cnt0 = 0
cnt1 = 0
ans = 0
com0 = 0
com1 = 0
for i in a:
	if i == '1':
		cnt1 += 1
	else:
		cnt0 += 1
for i in range(n):
	if b[i] == '0':
		if a[i] == '1':
			com1 += 1
		else:
			com0 += 1
for i in range(n):
	if b[i] == '0' and a[i] == '0':
		ans += cnt1
	elif b[i] == '0' and a[i] == '1':
		ans += cnt0
print(ans - com1 * com0)


n = int(input())
a = input()
b = input()
k = {}
d = {}
d['0'] = 0
d['1'] = 0
for c in a:
	d[c] += 1
k['0'] = 0
k['1'] = 0
for (i, c) in enumerate(a):
	v = b[i]
	if c == '0' and v == '0':
		k['0'] += 1
	elif c == '1' and v == '0':
		k['1'] += 1
total = 0
for (i, v) in enumerate(b):
	c = a[i]
	if v == '0' and c == '0':
		total += d['1'] - k['1']
	elif v == '0' and c == '1':
		total += d['0']
print(total)


n = int(input())
n1 = input().strip()
n2 = input().strip()
(a, b, c, d) = (0, 0, 0, 0)
for idx in range(n):
	(b1, b2) = (int(n1[idx]), int(n2[idx]))
	a += not b1
	b += b1
	c += (not b1) * (not b2)
	d += b1 * (not b2)
print(c * b + d * a - c * d)


from sys import stdin, stdout
import math, bisect
from collections import Counter, deque, defaultdict
L = lambda : list(map(int, stdin.readline().strip().split()))
M = lambda : map(int, stdin.readline().strip().split())
I = lambda : int(stdin.readline().strip())
S = lambda : stdin.readline().strip()
C = lambda : stdin.readline().strip().split()

def pr(a):
	return ' '.join(list(map(str, a)))

def solve():
	n = I()
	a = S()
	b = S()
	(x, y, z) = (0, 0, 0)
	for i in range(n):
		if b[i] == '0':
			x += a[i] == '1'
			y += a[i] == '0'
		else:
			z += a[i] == '1'
	print(y * z + x * a.count('0'))
for _ in range(1):
	solve()


n = int(input())
a = str(input())
b = str(input())
(x, y, z, t) = (0, 0, 0, 0)
for i in range(n):
	if a[i] == '0' and b[i] == '0':
		x += 1
	if a[i] == '0' and b[i] == '1':
		y += 1
	if a[i] == '1' and b[i] == '0':
		z += 1
	if a[i] == '1' and b[i] == '1':
		t += 1
print(x * z + x * t + y * z)


I = lambda : list(map(int, input().split()))
(n,) = I()
f = {}
a = input()
b = input()
s = 0
aa = 0
bb = 0
cc = 0
for i in range(n):
	if a[i] == '1':
		s += 1
	if a[i] == '0' and b[i] == '1':
		aa += 1
	elif a[i] == '1' and b[i] == '0':
		bb += 1
	elif a[i] == '0' and b[i] == '0':
		cc += 1
ans = 0
ans += cc * s + bb * aa
print(ans)


n = int(input())
a = input()
b = input()
index = []
zeros = 0
ones = 0
for i in range(n):
	if b[i] == '0':
		index.append(i)
	if a[i] == '0':
		zeros += 1
	else:
		ones += 1
ans = 0
interchange = 0
for i in index:
	if a[i] == '0':
		ans += ones
		zeros -= 1
	else:
		ans += zeros
		ones -= 1
print(ans)


n = int(input())
a = str(input())
b = str(input())
n1 = 0
n10 = 0
n00 = 0
n01 = 0
for i in range(n):
	if a[i] == '1':
		n1 += 1
		if b[i] == '0':
			n10 += 1
	elif b[i] == '0':
		n00 += 1
	else:
		n01 += 1
print(n00 * n1 + n10 * n01)


N = int(input(''))
str1 = list(input(''))
str2 = list(input(''))
cnt = 0
index_of_0_in_str2 = []
for i in range(0, N):
	str1[i] = int(str1[i])
index_of_outside = []
index_of_inside = []
for i in range(0, N):
	str2[i] = int(str2[i])
	if str2[i] == 1:
		index_of_outside.append(i)
	else:
		index_of_inside.append(i)
list_of_1_outside = []
for i in index_of_outside:
	if str1[i] == 1:
		list_of_1_outside.append(i)
a = len(list_of_1_outside)
c = len(index_of_outside) - a
list_of_1_inside = []
for i in index_of_inside:
	if str1[i] == 1:
		list_of_1_inside.append(i)
d = len(list_of_1_inside)
b = len(index_of_inside) - d
cnt = a * b + c * d + b * d
print(cnt)


n = int(input())
a = input()
b = input()
zeroesB = 0
ans = 0
zeroesA = onesA = 0
for x in range(n):
	if a[x] == '0':
		zeroesA += 1
	else:
		onesA += 1
zz = zo = 0
for x in range(n):
	if b[x] == '0':
		if a[x] == '0':
			zz += 1
			ans += onesA
		else:
			zo += 1
			ans += zeroesA
if zeroesA == n or onesA == n:
	print(0)
else:
	print(ans - zz * zo)


def justbit(n):
	count = 0
	while n > 0:
		count = count + 1
		n = n & n - 1
	return count
n1 = int(input())
a = input()
b = input()
set_a = 0
set_b = 0
set_c = 0
for i in range(n1):
	if a[i] == '1' and b[i] == '1':
		set_a += 1
		set_b += 1
		set_c += 1
	elif a[i] == '1':
		set_a += 1
	elif b[i] == '1':
		set_b += 1
	else:
		pass
part1 = set_b - set_c
part2 = set_c
minus = part1 * part2
r = set_a * (n1 - set_a)
print(r - minus)


ar1 = str(input())
ar2 = str(input())
ar3 = str(input())
nulnul = 0
odinnul = 0
odinodin = 0
nulodin = 0
nul = 0
odin = 0
for i in range(len(ar2)):
	if int(ar2[i]) == 0 and int(ar3[i]) == 0:
		nulnul += 1
	if int(ar2[i]) == 1 and int(ar3[i]) == 0:
		odinnul += 1
	if int(ar2[i]) == 1 and int(ar3[i]) == 1:
		odinodin += 1
	if int(ar2[i]) == 0 and int(ar3[i]) == 1:
		nulodin += 1
nul = ar2.count('0')
odin = ar2.count('1')
if nulnul * odin >= odinnul * nul:
	print(nulnul * odin + nulodin * odinnul)
else:
	print(odinnul * nul + odinodin * nulnul)


x = int(input())
y = list(input())
z = list(input())
a = [[i, j] for (i, j) in zip(y, z)]
b = a.count(['0', '0'])
c = a.count(['0', '1'])
d = a.count(['1', '0'])
e = a.count(['1', '1'])
print(b * (d + e) + c * d)


n = int(input())
x = [int(c) for c in input()]
y = [int(c) for c in input()]
counts = [0, 0, 0, 0]
for i in range(n):
	counts[2 * x[i] + y[i]] += 1
print(counts[0] * (counts[2] + counts[3]) + counts[1] * counts[2])


n = int(input())
bit1 = input()
onetot = 0
for item in bit1:
	if item == str(1):
		onetot += 1
bit2 = input()
s = ''
for i in range(n):
	if bit2[i] == str(0):
		s += str(bit1[i])
l = len(s)
onein = 0
for item in s:
	if item == str(1):
		onein += 1
zeroin = l - onein
oneout = onetot - onein
zeroout = n - l - oneout
totalways = oneout * zeroin + onein * zeroout + onein * zeroin
print(totalways)


n = int(input())
a = input()
b = input()
(cnt0, cnt1) = (0, 0)
for i in range(n):
	if a[i] == '0':
		cnt0 += 1
	else:
		cnt1 += 1
ans = 0
(t0, t1) = (0, 0)
for i in range(n):
	if b[i] == '0':
		if a[i] == '0':
			ans += cnt1
			t0 += 1
		else:
			ans += cnt0
			t1 += 1
print(ans - t0 * t1)


from collections import Counter, defaultdict
n = int(input())
a = list(map(int, input()))
b = list(map(int, input()))
c = list(zip(a, b))
C = defaultdict(int, Counter(c))
need = [C[0, 0], C[0, 1], C[1, 0], C[1, 1]]
ans = need[3] * need[0] + need[1] * need[2] + need[0] * need[2]
print(ans)


n = int(input())
A = list(input())
B = list(input())
m = 0
for elem in A:
	if elem == '0':
		m += 1
p = 0
q = 0
for i in range(n):
	if B[i] == '1':
		if A[i] == '1':
			p += 1
		elif A[i] == '0':
			q += 1
print((n - m) * m - p * q)


def go():
	n = int(input())
	a = [i for i in input()]
	b = [i for i in input()]
	total = 0
	i_o = [0] * n
	i_i = [0] * n
	o_i = [0] * n
	o_o = [0] * n
	if a[n - 1] == '0' and b[n - 1] == '0':
		o_o[n - 1] += 1
	elif a[n - 1] == '1' and b[n - 1] == '1':
		i_i[n - 1] += 1
	elif a[n - 1] == '0' and b[n - 1] == '1':
		o_i[n - 1] += 1
	elif a[n - 1] == '1' and b[n - 1] == '0':
		i_o[n - 1] += 1
	for i in range(n - 2, -1, -1):
		o_o[i] += o_o[i + 1]
		i_i[i] += i_i[i + 1]
		i_o[i] += i_o[i + 1]
		o_i[i] += o_i[i + 1]
		if a[i] == '0' and b[i] == '0':
			o_o[i] += 1
		elif a[i] == '1' and b[i] == '1':
			i_i[i] += 1
		elif a[i] == '0' and b[i] == '1':
			o_i[i] += 1
		elif a[i] == '1' and b[i] == '0':
			i_o[i] += 1
	for i in range(n - 1):
		if a[i] == '0' and b[i] == '1':
			total += i_o[i + 1]
		elif a[i] == '0' and b[i] == '0':
			total += i_i[i + 1]
			total += i_o[i + 1]
		elif a[i] == '1' and b[i] == '1':
			total += o_o[i + 1]
		elif a[i] == '1' and b[i] == '0':
			total += o_o[i + 1]
			total += o_i[i + 1]
	return total
print(go())


n = int(input())
a = list(map(int, list(input())))
b = list(map(int, list(input())))
ans = 0
_00 = 0
_01 = 0
_10 = 0
_11 = 0
for i in range(n):
	if a[i] == 0 and b[i] == 0:
		_00 += 1
	elif a[i] == 0 and b[i] == 1:
		_01 += 1
	elif a[i] == 1 and b[i] == 0:
		_10 += 1
	else:
		_11 += 1
ans = (_00 * (_11 + _10) + _01 * _10 + _10 * (_00 + _01) + _11 * _00) // 2
print(ans)


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

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

def li():
	return list(mi())
n = ii()
a = list(map(int, list(input().strip())))
b = list(map(int, list(input().strip())))
o = [0, 0]
z = [0, 0]
for i in range(n):
	if a[i]:
		o[b[i]] += 1
	else:
		z[b[i]] += 1
ans = z[0] * o[1] + z[1] * o[0] + z[0] * o[0]
print(ans)


from sys import stdin
from math import *
line = stdin.readline().rstrip().split()
n = int(line[0])
numbers = stdin.readline().rstrip().split()[0]
numbers2 = stdin.readline().rstrip().split()[0]
cant00 = 0
cant01 = 0
cant11 = 0
cant10 = 0
for i in range(len(numbers)):
	if numbers[i] == '0' and numbers2[i] == '0':
		cant00 += 1
	if numbers[i] == '1' and numbers2[i] == '0':
		cant01 += 1
	if numbers[i] == '0' and numbers2[i] == '1':
		cant10 += 1
	if numbers[i] == '1' and numbers2[i] == '1':
		cant11 += 1
print(cant00 * cant01 + cant00 * cant11 + cant01 * cant10)


n = int(input())
s1 = list(input())
s2 = list(input())
a = b = c = d = 0
for i in range(n):
	if s1[i] == '1' and s2[i] == '1':
		a += 1
	elif s1[i] == '0' and s2[i] == '0':
		b += 1
	elif s1[i] == '1' and s2[i] == '0':
		c += 1
	elif s1[i] == '0' and s2[i] == '1':
		d += 1
print(b * (a + c) + c * d)


n = int(input())
a = input()
b = input()
(res1, res2, res3, res4) = (0, 0, 0, 0)
for (x, y) in zip(a, b):
	if x == '1' and y == '0':
		res1 += 1
	if x == '0' and y == '1':
		res2 += 1
	if x == y == '0':
		res3 += 1
	if x == y == '1':
		res4 += 1
print(res2 * res1 + res3 * res4 + res3 * res1)


n = int(input())
(a, b) = (input(), input())
bit_pairs = list(map(''.join, zip(a, b)))
pair_types = ('00', '01', '10', '11')
p = {key: bit_pairs.count(key) for key in pair_types}
print((p['00'] * (p['10'] + p['11']) + p['01'] * p['10'] + p['10'] * (p['01'] + p['00']) + p['11'] * p['00']) // 2)


n = int(input())
string1 = input()
string2 = input()
a = b = c = d = 0
for i in range(n):
	if string1[i] == '0' and string2[i] == '0':
		a += 1
	elif string1[i] == '0' and string2[i] == '1':
		b += 1
	elif string1[i] == '1' and string2[i] == '0':
		c += 1
	else:
		d += 1
print(a * c + a * d + b * c)


n = int(input().strip())
a = input().strip()
b = input().strip()
zz = 0
oz = 0
zo = 0
oo = 0
for i in range(len(a)):
	if a[i] == '0' and b[i] == '0':
		zz += 1
	if a[i] == '1' and b[i] == '0':
		oz += 1
	if a[i] == '0' and b[i] == '1':
		zo += 1
	if a[i] == '1' and b[i] == '1':
		oo += 1
print(oo * zz + oz * zo + oz * zz)


R = lambda : map(int, input())
input()
c = [0] * 4
for (x, y) in zip(R(), R()):
	c[x + y * 2] += 1
print(c[0] * (c[1] + c[3]) + c[1] * c[2])


import sys
sys.setrecursionlimit(10000000)
mod = 10 ** 9 + 7
digl = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
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 = si()
s2 = si()
(c0, c1) = (0, 0)
ts = 0
for i in range(n):
	if s1[i] == '1':
		c1 += 1
	if s1[i] == '0' and s2[i] != '0':
		c0 += 1
for i in range(n):
	if s2[i] == '0' and s1[i] == '1':
		ts += c0
	if s2[i] == '0' and s1[i] == '0':
		ts += c1
print(ts)


n = int(input())
a = input()
b = input()
c = [0, 0, 0, 0]
for i in range(n):
	c[2 * int(a[i]) + int(b[i])] += 1
print(c[3] * c[0] + c[0] * c[2] + c[2] * c[1])


def bit(a, b, n):
	a0 = [0, 0]
	a1 = [0, 0]
	for i in range(n):
		if b[i] == '0':
			if a[i] == '0':
				a0[0] += 1
			else:
				a0[1] += 1
		elif a[i] == '0':
			a1[0] += 1
		else:
			a1[1] += 1
	s = 0
	s += a0[0] * a1[1] + a0[1] * a1[0]
	s += a0[0] * a0[1]
	print(s)
n = int(input())
a = input()
b = input()
bit(a, b, n)


n_bits = int(input())
a = [int(x) for x in input()]
b = [int(x) for x in input()]
a_in = [a[i] for (i, x) in enumerate(b) if not x]
a_out = [a[i] for (i, x) in enumerate(b) if x]
print(a_in.count(0) * a.count(1) + a_in.count(1) * a_out.count(0))


def bytes(x, y):
	a = [0] * 4
	for i in range(len(x)):
		count = 0
		if x[i] == '1':
			count |= 1
		if y[i] == '1':
			count |= 2
		a[count] += 1
	return a[0] * a[3] + a[1] * a[2] + a[0] * a[1]
n = int(input())
s = input()
t = input()
print(bytes(s, t))


n = int(input())
a = input()
b = input()
(x, y, z, w) = (0, 0, 0, 0)
for i in range(n):
	if a[i] == '0':
		if b[i] == '0':
			w += 1
		else:
			x += 1
	elif b[i] == '0':
		y += 1
	else:
		z += 1
print(w * (y + z) + y * x)


n = int(input())
a = [*map(int, list(input()))]
b = [*map(int, list(input()))]
one = sum(a)
zero = len(a) - one
ans = 0
wk1 = 0
wk2 = 0
for i in range(n):
	if b[i] == 0:
		if a[i] == 0:
			ans += one
			wk1 += 1
		else:
			ans += zero
			wk2 += 1
print(ans - wk1 * wk2)


n = int(input())
a = list(input())
b = list(input())
n0 = n1 = 0
for i in range(n):
	if b[i] == '0':
		if a[i] == '0':
			n0 += 1
		else:
			n1 += 1
zero = a.count('0')
one = a.count('1')
suma = one * n0
zero -= n0
suma += zero * n1
print(suma)


I = lambda : list(map(int, input().split()))
MOD = 1000000007
(n,) = I()
s = input()
t = input()
pos = 0
pos2 = 0
pos3 = 0
pos4 = 0
for i in range(n):
	k = s[i] + t[i]
	if k == '00':
		pos += 1
	if k == '01':
		pos2 += 1
	if k == '10':
		pos3 += 1
	if k == '11':
		pos4 += 1
print(pos * (pos3 + pos4) + pos2 * pos3)


n = int(input())
a = list(input())
b = list(input())
ans = [0] * 4
s1 = [0, 0, 1, 1]
s2 = [0, 1, 0, 1]
for i in range(n):
	for j in range(4):
		if int(a[i]) == s1[j] and int(b[i]) == s2[j]:
			ans[j] += 1
print(ans[0] * ans[2] + ans[0] * ans[3] + ans[1] * ans[2])


n = int(input())
a = input()
b = input()
d = {'00': 0, '01': 0, '10': 0, '11': 0}
for i in range(n):
	d[a[i] + b[i]] += 1
print(d['01'] * d['10'] + d['10'] * d['00'] + d['11'] * d['00'])


def main():
	l = int(input())
	a = input()
	b = input()
	ct = 0
	lb0 = 0
	in1 = 0
	out1 = 0
	out0 = 0
	for i in range(l):
		if b[i] == '0':
			lb0 += 1
			if a[i] == '1':
				in1 += 1
		elif a[i] == '1':
			out1 += 1
		else:
			out0 += 1
	ct += in1 * (lb0 - in1)
	ct += (lb0 - in1) * out1
	ct += in1 * out0
	print(ct)
main()


from collections import Counter

def main():
	n = int(input())
	(s1, s2) = (input(), input())
	c = Counter()
	for i in range(n):
		c[s1[i] + s2[i]] += 1
	print(c['10'] * (c['00'] + c['01']) + c['00'] * c['11'])
main()


n = int(input())
l1 = input()
l2 = input()
li = [0, 0, 0, 0]
for i in range(n):
	if l1[i] == '1' and l2[i] == '1':
		li[0] += 1
	elif l1[i] == '1' and l2[i] == '0':
		li[1] += 1
	elif l1[i] == '0' and l2[i] == '0':
		li[2] += 1
	elif l1[i] == '0' and l2[i] == '1':
		li[3] += 1
print(li[0] * li[2] + li[1] * li[3] + li[2] * li[1])


n = int(input())
a = input()
b = input()
(zc, oc) = (0, 0)
(zs, os) = (0, 0)
for i in range(n):
	if a[i] == '0':
		zc += 1
		if b[i] == '0':
			zs += 1
	else:
		oc += 1
		if b[i] == '0':
			os += 1
print(zc * os + zs * oc - zs * os)


n = int(input())
l1 = input()
l2 = input()
s1 = s2 = s3 = s4 = 0
for (i, j) in zip(l1, l2):
	if i == '1' and j == '0':
		s1 += 1
	elif i == '0' and j == '1':
		s2 += 1
	elif i == '1' and j == '1':
		s3 += 1
	else:
		s4 += 1
print(s1 * (s2 + s4) + s3 * s4)


t = int(input())
a = input()
b = input()
c = 0
zz = 0
zo = 0
b0 = b.count('0')
b1 = b.count('1')
a1 = a.count('1')
a0 = a.count('0')
if a1 == t or b1 == t:
	c = 0
else:
	cnt1 = 0
	cnt2 = 0
	for i in range(t):
		if b[i] == '0' and a[i] == '1':
			zo += a0
			zo -= cnt2
			cnt1 += 1
		if b[i] == '0' and a[i] == '0':
			zz += a1
			zz -= cnt1
			cnt2 += 1
print(zo + zz)


length = int(input())
bit1 = input()
bit2 = input()
q00 = 0
q11 = 0
q10 = 0
q01 = 0
zlist = []
result = 0
for a in range(length):
	if bit1[a] == '1':
		if bit2[a] == '0':
			q10 += 1
			zlist.append(a)
		else:
			q11 += 1
	elif bit2[a] == '0':
		q00 += 1
		zlist.append(a)
	else:
		q01 += 1
for a in zlist:
	if bit1[a] == '1':
		result += q01
	else:
		result += q10 + q11
print(result)


n = int(input())
(a, b) = (input(), input())
ans = 0
aa = 0
bb = 0
for i in range(n):
	if b[i] == '1':
		if a[i] == '1':
			aa += 1
	if a[i] == '0':
		bb += 1
for i in range(n):
	if b[i] == '0':
		if a[i] == '0':
			ans += aa
		else:
			ans += bb
print(ans)


n = int(input())
a = str(input())
b = str(input())
c1 = 0
c2 = 0
for i in range(n):
	if b[i] == '0':
		if a[i] == '1':
			c1 += 1
		if a[i] == '0':
			c2 += 1
one = a.count('1')
zero = a.count('0')
ans1 = c1 * zero + c2 * one
ans = ans1 - c1 * c2
print(ans)


n = int(input())
a = str(input())
b = str(input())
m = [0, 0, 0, 0]
for i in range(0, n):
	m[int(a[i]) + 2 * int(b[i])] += 1
print(m[0] * m[1] + m[0] * m[3] + m[1] * m[2])


n = int(input())
a = input()
b = input()
t01 = t10 = t00 = t11 = 0
for i in range(n):
	if a[i] == '0' and b[i] == '0':
		t00 += 1
	if a[i] == '0' and b[i] == '1':
		t01 += 1
	if a[i] == '1' and b[i] == '0':
		t10 += 1
	if a[i] == '1' and b[i] == '1':
		t11 += 1
print(t00 * t11 + t10 * t00 + t10 * t01)


n = int(input())
s = input()
t = input()
(ch_ones, ch_zeros) = (0, 0)
(ones, zeros) = (0, 0)
for i in range(n):
	if s[i] == '1':
		ones += 1
	else:
		zeros += 1
	if s[i] == '1' and t[i] == '0':
		ch_ones += 1
	if s[i] == '0' and t[i] == '0':
		ch_zeros += 1
print(ch_zeros * ones + ch_ones * zeros - ch_ones * ch_zeros)


t = int(input())
a = input()
b = input()
s = 0
nz = 0
nn = 0
c1 = a.count('1')
c2 = a.count('0')
for i in range(t):
	if b[i] == '0':
		if a[i] == '0':
			nz += 1
			s += c1
		else:
			nn += 1
			s += c2
print(s - nn * nz)


n = int(input())
a = list(input())
b = list(input())
other_0 = other_1 = imp_0 = imp_1 = 0
for i in range(n):
	if b[i] == '1':
		if a[i] == '0':
			other_0 += 1
		else:
			other_1 += 1
	elif a[i] == '0':
		imp_0 += 1
	else:
		imp_1 += 1
print(imp_0 * other_1 + imp_1 * other_0 + imp_0 * imp_1)


n = int(input())
a = [int(i) for i in input()]
b = [int(i) for i in input()]
r = [0, 0]
k = 0
for e in a:
	r[e] += 1
for (i, e) in enumerate(a):
	if b[i] != 1:
		r[e] -= 1
		k += r[1 - e]
print(k)


n = int(input())
s1 = input()
s2 = input()
a = b = c = d = 0
for i in range(n):
	if s1[i] == '1':
		if s2[i] == '1':
			a += 1
		else:
			b += 1
	elif s2[i] == '0':
		c += 1
	else:
		d += 1
res = a * c + b * c + b * d
print(res)


n = int(input())
first = input()
second = input()
one_one = 0
zero_zero = 0
zero_one = 0
one_zero = 0
for i in range(n):
	f = int(first[i])
	s = int(second[i])
	if f * s == 1:
		one_one += 1
	elif f + s == 0:
		zero_zero += 1
	elif f == 0:
		zero_one += 1
	else:
		one_zero += 1
ways = zero_zero * (one_one + one_zero) + one_zero * zero_one
print(ways)


n = int(input())
a = input()
b = input()
ii = 0
zz = 0
iz = 0
zi = 0
for i in range(n):
	if a[i] == b[i]:
		if a[i] == '1':
			ii += 1
		else:
			zz += 1
	elif a[i] == '1':
		iz += 1
	else:
		zi += 1
ans = ii * zz + iz * zz + iz * zi
print(ans)


n = int(input())
a = input()
b = input()
(c00, c10, c01, c11) = (0, 0, 0, 0)
for i in range(n):
	if a[i] == '0' and b[i] == '0':
		c00 += 1
	if a[i] == '1' and b[i] == '0':
		c10 += 1
	if a[i] == '0' and b[i] == '1':
		c01 += 1
	if a[i] == '1' and b[i] == '1':
		c11 += 1
tot = c11 * c00 + c10 * (c00 + c01)
print(tot)


n = int(input())
a = input()
b = input()
ao = a.count('1')
az = n - ao
(u, v) = (0, 0)
for i in range(n):
	if b[i] == '0':
		if a[i] == '1':
			u += 1
		else:
			v += 1
print(u * az + v * ao - u * v)


n = int(input())
s1 = input()
s2 = input()
ones = sum(map(int, s1))
zeros = n - ones
s = sorted(zip(s1, s2), key=lambda x: x[1])
allSums = []
for (x, y) in s:
	if y == '1':
		break
	if x == '0':
		zeros -= 1
		allSums.append(ones)
	else:
		ones -= 1
		allSums.append(zeros)
print(sum(allSums))


n = int(input())
a = input()
b = input()
c = 0
d = 0
for i in range(n):
	if a[i] == '0' and b[i] == '0':
		c += 1
	elif a[i] == '1' and b[i] == '0':
		d += 1
k = a.count('1')
ans = 0
ans += c * k
k = a.count('0')
ans += d * k
ans -= c * d
print(ans)


n = int(input())
a = input()
b = input()
zeros = 0
ones = 0
d_zeros = 0
d_ones = 0
for (x, y) in zip(a, b):
	if x != y:
		if x == '0':
			zeros += 1
			d_zeros += 1
		else:
			ones += 1
			d_ones += 1
	elif x == '0':
		zeros += 1
	else:
		ones += 1
ans = (ones - d_ones) * (zeros - d_zeros) + d_ones * (zeros - d_zeros) + d_ones * d_zeros
print(ans)


n = int(input())
a = input()
b = input()
m = 0
d = 0
for i in range(n):
	if a[i] == '1':
		m += 1
	elif b[i] == '1':
		d += 1
ans = 0
for i in range(n):
	if b[i] == '0':
		if a[i] == '0':
			ans += m
		else:
			ans += d
print(ans)


n = int(input())
a = str(input())
b = str(input())
one = 0
two = 0
three = 0
four = 0
for i in range(n):
	if a[i] == '0' and b[i] == '0':
		one += 1
	elif a[i] == '0' and b[i] == '1':
		two += 1
	elif a[i] == '1' and b[i] == '0':
		three += 1
	else:
		four += 1
print(one * four + two * three + one * three)


def mi():
	return map(int, input().split())
n = int(input())
a = list(map(int, input()))
b = list(map(int, input()))
(zz, zo, oz, oo) = (0, 0, 0, 0)
for i in range(n):
	if a[i] == 1 and b[i] == 1:
		oo += 1
	elif a[i] == 0 and b[i] == 0:
		zz += 1
	elif a[i] == 1 and b[i] == 0:
		oz += 1
	else:
		zo += 1

def nc2(n):
	return n
cnt = 0
cnt += zz * (oz + oo) + zo * oz
print(cnt)


n = int(input())
a = input()
b = input()
one_count = 0
zer_count = 0
common_z = 0
common_o = 0
for i in range(n):
	if a[i] == '1':
		one_count += 1
	if a[i] == '0':
		zer_count += 1
	if b[i] == '0':
		if a[i] == '0':
			common_z += 1
		if a[i] == '1':
			common_o += 1
tot = 0
for i in range(n):
	if b[i] == '0':
		if a[i] == '0':
			tot += one_count
		if a[i] == '1':
			tot += zer_count
print(tot - common_z * common_o)


n = int(input())
a = list(input())
b = list(input())
os = a.count('0')
ik = a.count('1')
ans = 0
for i in range(n):
	if a[i] == '1' and b[i] == '0' and (os > 0):
		ans += os
		ik -= 1
	elif a[i] == '0' and b[i] == '0' and (ik > 0):
		ans += ik
		os -= 1
print(ans)


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


n = int(input())
a = list(input())
b = list(input())
total_ceros = dobles = uno_cero = unos = 0
for i in range(n):
	if a[i] == '0' and b[i] == '0':
		dobles += 1
	if a[i] == '0':
		total_ceros += 1
	else:
		unos += 1
	if a[i] == '1' and b[i] == '0':
		uno_cero += 1
print(dobles * unos + (total_ceros - dobles) * uno_cero)


n = int(input())
a = [int(x) for x in input().strip()]
b = [int(x) for x in input().strip()]
(p, q, r, s) = (0, 0, 0, 0)
for i in range(n):
	if a[i] * 2 + b[i] == 0:
		p += 1
	if a[i] * 2 + b[i] == 1:
		q += 1
	if a[i] * 2 + b[i] == 2:
		r += 1
	if a[i] * 2 + b[i] == 3:
		s += 1
print(p * r + p * s + q * r)


input()
a = [int(i) for i in input()]
(o, z) = (0, 0)
for i in a:
	if i == 0:
		z += 1
	else:
		o += 1
p = 0
b = input()
for i in range(0, len(b)):
	if b[i] == '0':
		a[p] = a[i]
		p += 1
res = 0
for i in range(0, p):
	if a[i] == 0:
		res += o
		z -= 1
	else:
		res += z
		o -= 1
print(res)


n = int(input())
s1 = input()
s2 = input()
a = [0] * 2
for i in s1:
	a[int(i)] += 1
cnt = 0
c1 = 0
c2 = 0
for i in range(n):
	if s1[i] == '0' and s2[i] == '0':
		c1 += 1
	if s1[i] == '1' and s2[i] == '0':
		c2 += 1
for i in range(n):
	if s1[i] == '0' and s2[i] == '0':
		cnt += a[1] - c2
	if s1[i] == '1' and s2[i] == '0':
		cnt += a[0]
print(cnt)


(n, a, b) = (int(input()), input(), input())
oo = sum((a[i] == '0' and b[i] == '0' for i in range(n)))
ol = sum((a[i] == '0' and b[i] == '1' for i in range(n)))
lo = sum((a[i] == '1' and b[i] == '0' for i in range(n)))
ll = sum((a[i] == '1' and b[i] == '1' for i in range(n)))
print(oo * lo + ll * oo + lo * ol)


a = int(input())
(_10, _01, _00, _11) = (0, 0, 0, 0)
for (i, j) in zip(input(), input()):
	if i == '1' and j == '0':
		_10 += 1
	elif i == '0' and j == '1':
		_01 += 1
	elif i == '0' and j == '0':
		_00 += 1
	else:
		_11 += 1
print(_10 * _01 + _00 * _11 + _00 * _10)


n = int(input())
s1 = input()
s2 = input()
smth = dict()
smth['01'] = 0
smth['00'] = 0
smth['10'] = 0
smth['11'] = 0
ans = 0
for i in range(n):
	smth[s1[i] + s2[i]] += 1
for i in range(n):
	if s1[i] == '0':
		if s2[i] == '0':
			ans += smth['10']
			ans += smth['11']
		else:
			ans += smth['10']
print(ans)


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


n = int(input())
a = input()
b = input()
c = []
d = []
e = []
for i in range(0, 200):
	e.append(0)
for i in range(0, n):
	c.append(int(a[i]))
	d.append(int(b[i]))
	e[c[i] * 2 + d[i]] += 1
print(e[0] * e[2] + e[0] * e[3] + e[1] * e[2])


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


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


from collections import Counter
n = int(input())
a = input()
b = input()
arr_z = [0, 0]
for (i, el) in enumerate(b):
	if el == '0':
		if a[i] == '0':
			arr_z[0] += 1
		else:
			arr_z[1] += 1
c = Counter(a)
arr_z_a = [c['0'], c['1']]
print(arr_z[0] * arr_z_a[1] + arr_z[1] * arr_z_a[0] - arr_z[0] * arr_z[1])


n = int(input())
a = list(input())
b = list(input())
onereq = []
zeroreq = []
index1 = []
index0 = []
for i in range(len(a)):
	bita = a[i]
	bitb = b[i]
	if bita == '0':
		index0.append(i)
	else:
		index1.append(i)
	if bita == '0' and bitb == '1':
		onereq.append(i)
	if bita == '1' and bitb == '1':
		zeroreq.append(i)
print(len(index0) * len(index1) - len(zeroreq) * len(onereq))


N = int(input())
a = input()
b = input()
Count = [0, 0, 0, 0]
for i in range(N):
	if a[i] == '0' and b[i] == '0':
		Count[0] += 1
	elif a[i] == '0' and b[i] == '1':
		Count[1] += 1
	elif a[i] == '1' and b[i] == '0':
		Count[2] += 1
	else:
		Count[3] += 1
print(Count[0] * (Count[2] + Count[3]) + Count[2] * Count[1])


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


n = int(input())
s = input()
a = [s[i] == '1' for i in range(0, n)]
s = input()
b = [s[i] == '1' for i in range(0, n)]
c00 = 0
c10 = 0
c1 = 0
c01 = 0
for i in range(0, n):
	if a[i]:
		c1 += 1
		if not b[i]:
			c10 += 1
	elif b[i]:
		c01 += 1
	else:
		c00 += 1
print(c00 * c1 + c10 * c01)


n = int(input())
a = input()
b = input()
v0 = 0
v1 = 0
n0 = 0
n1 = 0
for i in range(n):
	if b[i] == '0':
		if a[i] == '0':
			v0 += 1
		else:
			v1 += 1
	elif a[i] == '0':
		n0 += 1
	else:
		n1 += 1
print(v0 * n1 + v1 * n0 + v1 * v0)


from __future__ import print_function
import sys
import math
import os.path
from copy import deepcopy
from functools import reduce
from collections import Counter, ChainMap, defaultdict
from itertools import cycle, chain
from queue import Queue, PriorityQueue
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, nlargest, nsmallest
import bisect
from statistics import mean, mode, median, median_low, median_high
sys.setrecursionlimit(10 ** 9)

def log(*args, **kwargs):
	print(*args, file=sys.stderr, **kwargs)

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

def nio(offset):
	return map(lambda x: int(x) + offset, input().split())

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

def toString(aList, sep=' '):
	return sep.join((str(x) for x in aList))

def toMapInvertIndex(aList):
	return {k: v for (v, k) in enumerate(aList)}

def sortId(arr):
	return sorted(range(len(arr)), key=lambda k: arr[k])
(n,) = ni()
a = input()
b = input()
(c00, c11, c01, c10) = (0, 0, 0, 0)
count = 0
for i in range(n):
	if a[i] == '0' and b[i] == '0':
		c00 += 1
	if a[i] == '1' and b[i] == '1':
		c11 += 1
	if a[i] == '0' and b[i] == '1':
		c01 += 1
	if a[i] == '1' and b[i] == '0':
		c10 += 1
count += c00 * c11
count += c10 * c00
count += c10 * c01
print(count)


n = int(input())
a = input()
b = input()
count_a = [a.count('0'), a.count('1')]
count_b = [b.count('0'), b.count('1')]
bz = []
b_front = [0, 0]
for i in range(n):
	if b[i] == '0':
		bz.append(i)
		b_front[int(a[i])] += 1
answer = 0
for index in bz:
	answer += count_a[1 - int(a[index])]
print(answer - b_front[0] * b_front[1])


from collections import defaultdict
import sys, heapq, bisect, math, itertools, string, queue, datetime
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
mod = 10 ** 9 + 7
eps = 10 ** (-7)
AtoZ = [chr(i) for i in range(65, 65 + 26)]
atoz = [chr(i) for i in range(97, 97 + 26)]

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

def inpl_s():
	return list(input().split())
N = int(input())
aa = list(map(int, list(input())))
bb = list(map(int, list(input())))
x00 = x01 = x10 = x11 = 0
for i in range(N):
	if aa[i] and bb[i]:
		x11 += 1
	elif not aa[i] and bb[i]:
		x01 += 1
	elif aa[i] and (not bb[i]):
		x10 += 1
	else:
		x00 += 1
print(x00 * (x10 + x11) + x10 * x01)


import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(n,) = I()
a = input()
b = input()
z = o = zo = oz = an = 0
for i in range(n):
	z += (a[i] == b[i]) * (a[i] == '0')
	o += (a[i] == b[i]) * (a[i] == '1')
	zo += (a[i] != b[i]) * (a[i] == '0')
	oz += (a[i] != b[i]) * (a[i] == '1')
print(z * o + z * oz + oz * zo)


n = int(input())
a = list(input())
b = list(input())
x = 0
y = 0
c = 0
d = 0
for i in range(n):
	if a[i] == '1' and b[i] == '0':
		x += 1
	if a[i] == '0' and b[i] == '0':
		y += 1
	if a[i] == '1':
		c += 1
	if a[i] == '0':
		d += 1
print(x * d + y * c - x * y)


n = int(input())
s1 = input()
s2 = input()
c_0 = s1.count('0')
c_1 = n - c_0
cnt = 0
c00 = 0
c10 = 0
for i in range(n):
	if s2[i] == '0':
		if s1[i] == '0':
			cnt += c_1 - c10
			c00 += 1
		else:
			cnt += c_0 - c00
			c10 += 1
print(cnt)


ans = {'0': {'0': 0, '1': 0}, '1': {'0': 0, '1': 0}}
n = int(input())
(a, b) = (input(), input())
for i in range(n):
	ans[a[i]][b[i]] += 1
print(ans['0']['0'] * ans['1']['1'] + ans['1']['0'] * (ans['0']['0'] + ans['0']['1']))


n = int(input())
a = input()
b = input()
c = 0
d = 0
e = 0
f = 0
for i in range(n):
	if a[i] == '1' and b[i] == '1':
		c += 1
	elif a[i] == '1' and b[i] == '0':
		d += 1
	elif a[i] == '0' and b[i] == '1':
		e += 1
	else:
		f += 1
print(c * f + d * (e + f))


import math
import itertools
from collections import defaultdict
getInputList = lambda : list(raw_input().split())
getInputIntList = lambda : list(map(int, raw_input().split()))
n = int(input())
a = list(input())
b = list(input())
c0 = a.count('0')
c1 = a.count('1')
ans = 0
for i in range(n):
	if b[i] == '1':
		continue
	elif a[i] == '1':
		ans += c0
		c1 -= 1
	else:
		ans += c1
		c0 -= 1
print(ans)


n = int(input())
a = input()
b = input()
zo = {(0, 0): 0, (0, 1): 0, (1, 0): 0, (1, 1): 0}
for (c, d) in zip(a, b):
	zo[int(c), int(d)] += 1
print(zo[0, 0] * (zo[1, 0] + zo[1, 1]) + zo[1, 0] * zo[0, 1])


from collections import deque as de
import math
from collections import Counter as cnt
from functools import reduce
from typing import MutableMapping

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

class My_stack:

	def __init__(self):
		self.data = []

	def my_push(self, x):
		return self.data.append(x)

	def my_pop(self):
		return self.data.pop()

	def my_peak(self):
		return self.data[-1]

	def my_contains(self, x):
		return self.data.count(x)

	def my_show_all(self):
		return self.data

	def isEmpty(self):
		return len(self.data) == 0
arrStack = My_stack()

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

def get_prime_factors(number):
	prime_factors = []
	while number % 2 == 0:
		prime_factors.append(2)
		number = number / 2
	for i in range(3, int(math.sqrt(number)) + 1, 2):
		while number % i == 0:
			prime_factors.append(int(i))
			number = number / i
	if number > 2:
		prime_factors.append(int(number))
	return prime_factors

def get_frequency(list):
	dic = {}
	for ele in list:
		if ele in dic:
			dic[ele] += 1
		else:
			dic[ele] = 1
	return dic

def Log2(x):
	return math.log10(x) / math.log10(2)

def isPowerOfTwo(n):
	return math.ceil(Log2(n)) == math.floor(Log2(n))
n = int(input())
a = input()
b = input()
ans = 0
nzc = 0
noc = 0
for i in range(n):
	if b[i] == '0':
		if a[i] == '0':
			nzc += 1
		else:
			noc += 1
totalzerocount = a.count('0')
totalonecount = a.count('1')
ans = nzc * (totalonecount - noc) + nzc * noc + noc * (totalzerocount - nzc)
print(ans)


n = int(input())
a = list(input())
b = list(input())
num_zeroes = a.count('0')
num_ones = a.count('1')
count = 0
bta0s = 0
bta1s = 0
for i in range(0, n):
	if b[i] == '0':
		if a[i] == '0':
			count += num_ones
			bta0s += 1
		else:
			count += num_zeroes
			bta1s += 1
count -= bta0s * bta1s
print(count)


n = int(input())
a = str(input())
b = str(input())
co = 0
de = 0
dd = 0
for i in range(n):
	if b[i] == '0':
		if a[i] == '0':
			k = a.count('1') - dd
			co += k
			de += 1
		else:
			k = a.count('0') - de
			co += k
			dd += 1
print(co)


n = int(input())
s1 = str(input())
s2 = str(input())
ans1 = 0
ans2 = 0
ans3 = 0
ans4 = 0
for i in range(n):
	if s2[i] == '0' and s1[i] == '1':
		ans1 += 1
	elif s2[i] == '0' and s1[i] == '0':
		ans2 += 1
	if s1[i] == '1':
		ans3 += 1
	if s1[i] == '0':
		ans4 += 1
ansx = 0
ansy = 0
for i in range(n):
	if s2[i] == '0' and s1[i] == '0':
		ansx += ans3 - ans1
		ansy += ans1
	elif s2[i] == '0' and s1[i] == '1':
		ansx += ans4 - ans2
		ansy += ans2
ans = ansx
ans += ansy // 2
print(ans)


n = int(input())
a = input()
b = input()
if len(set(a)) == 1:
	print(0)
else:
	ed = 0
	zer = 0
	for i in a:
		if i == '0':
			zer += 1
		else:
			ed += 1
	sed = szer = 0
	for i in range(n):
		if b[i] == '0':
			if a[i] == '0':
				szer += 1
			else:
				sed += 1
	print(sed * zer + szer * ed - szer * sed)


n = int(input())
t1 = input()
t2 = input()
one = 0
zero = 0
ext0 = 0
ext1 = 0
for i in range(len(t1)):
	if t1[i] == '1':
		one = one + 1
	else:
		zero = zero + 1
to = 0
for i in range(len(t2)):
	if t2[i] == '0':
		if t1[i] == '0':
			ext0 = ext0 + 1
			to = to + one
		if t1[i] == '1':
			ext1 = ext1 + 1
			to = to + zero
print(to - ext0 * ext1)


n = int(input())
s = input()
s1 = input()
t00 = 0
t01 = 0
t10 = 0
t11 = 0
for i in range(n):
	if s[i] == '0' and s1[i] == '0':
		t00 += 1
	if s[i] == '0' and s1[i] == '1':
		t01 += 1
	if s[i] == '1' and s1[i] == '0':
		t10 += 1
	if s[i] == '1' and s1[i] == '1':
		t11 += 1
print(t00 * t10 + t01 * t10 + t11 * t00)


n = int(input())
a = input()
b = input()
num0 = 0
num1 = 0
numUnlocked0 = 0
numUnlocked1 = 0
for i in range(n):
	if a[i] == '0':
		if b[i] == '0':
			numUnlocked0 += 1
		num0 += 1
	else:
		if b[i] == '0':
			numUnlocked1 += 1
		num1 += 1
answer = numUnlocked0 * num1 + numUnlocked1 * num0 - numUnlocked0 * numUnlocked1
print(answer)


n = int(input())
s_1 = input()
s_2 = input()
check = s_1.count('0')
s = 0
k = 0
for i in range(n):
	if s_1[i] == '1' and s_2[i] == '1':
		k += 1
for i in range(n):
	if s_1[i] == '0' and s_2[i] == '0':
		s += k
	if s_1[i] == '1' and s_2[i] == '0':
		s += check
print(s)


def cin(obj=list, type=int, sep=' '):
	return obj(map(type, input().split(sep)))
(n,) = cin()
a = input()
b = input()
on = a.count('1')
z = 0
for (x1, x2) in zip(a, b):
	if x1 == '0' and x2 != '0':
		z += 1
ans = 0
for (x1, x2) in zip(a, b):
	if x1 == x2 == '0':
		ans += on
	if x1 == '1' and x2 == '0':
		ans += z
print(ans)


import time
n = int(input())
a = input()
b = input()
start = time.time()
p00 = 0
p11 = 0
p10 = 0
p01 = 0
for i in range(n):
	if a[i] == '0':
		if b[i] == '0':
			p00 += 1
		else:
			p01 += 1
	elif b[i] == '0':
		p10 += 1
	else:
		p11 += 1
ans = p00 * p11 + p10 * p01 + p00 * p10
print(ans)
finish = time.time()


from collections import defaultdict
n = int(input())
num1 = input()
num2 = input()
dict = defaultdict(int)
for (x, y) in zip(num1, num2):
	dict[x] += 1
	dict[x, y] += 1
result = dict['0', '0'] * dict['1'] + dict['0', '1'] * dict['1', '0'] + dict['1', '0'] * dict['0'] + dict['1', '1'] * dict['0', '0']
print(result // 2)


N = input()
a = map(int, input())
b = map(int, input())
c = [0] * 4
for (i, j) in zip(a, b):
	c[i + 2 * j] += 1
print(c[0] * c[1] + c[0] * c[3] + c[1] * c[2])


import sys
inp = sys.stdin.readlines()
ii = 0
out = []
t = int(inp[ii])
ii += 1
a = inp[ii]
ii += 1
b = inp[ii]
ii += 1
(x, y) = (0, 0)
for i in range(t):
	if a[i] == '1' and b[i] == '0':
		y += 1
	if a[i] == '0' and b[i] == '0':
		x += 1
sys.stdout.write(str(x * a.count('1') + (a.count('0') - x) * y))


n = int(input())
s = str(input())
p = str(input())
(zero, one) = (0, 0)
for j in range(n):
	if s[j] == '0' and p[j] == '1':
		zero += 1
	if s[j] == '1':
		one += 1
count = 0
for j in range(n):
	if p[j] == '0':
		if s[j] == '0':
			count += one
		else:
			count += zero
print(count)


n = int(input())
a = input()
b = input()
counter = 0
pairs = [0, 0, 0, 0]
for i in range(n):
	if a[i] == b[i] and a[i] == '0':
		pairs[0] += 1
	elif a[i] == b[i]:
		pairs[3] += 1
	elif a[i] != b[i] and a[i] == '0':
		pairs[1] += 1
	else:
		pairs[2] += 1
counter += pairs[0] * pairs[3]
counter += pairs[1] * pairs[2]
counter += pairs[2] * pairs[0]
print(counter)


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()
s0 = input()
s1 = input()
zz = collections.Counter()
for i in range(N):
	t = (s0[i], s1[i])
	zz[t] += 1
res = 0
res += zz['0', '1'] * zz['1', '0']
res += zz['0', '0'] * zz['1', '0']
res += zz['0', '0'] * zz['1', '1']
print(res)


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

def LI():
	return 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 JA(a, sep):
	return sep.join(map(str, a))

def main():
	n = I()
	a = S()
	b = S()
	c = collections.defaultdict(int)
	r = 0
	for i in range(n):
		t = int(a[i]) * 2 + int(b[i])
		if t == 0:
			r += c[2]
			r += c[3]
		elif t == 1:
			r += c[2]
		elif t == 2:
			r += c[0]
			r += c[1]
		else:
			r += c[0]
		c[t] += 1
	return r
print(main())


n = int(input())
(a, b) = (input(), input())
d = bin(int(a, 2) | int(b, 2))[2:]
d = n - len(d) + d.count('0')
cnt = int(a.count('1')) * d
c = bin(int(a, 2) ^ int(b, 2))[2:]
c = (c.count('1') - bin(int(a, 2) & int(c, 2)).count('1')) * bin(int(a, 2) & int(c, 2)).count('1')
print(c + cnt)


n = int(input())
a = input()
b = input()
(cnt_1, cnt_2, cnt_3, cnt_4) = (0, 0, 0, 0)
for (bit_a, bit_b) in zip(a, b):
	if bit_a == '1' and bit_b == '0':
		cnt_1 += 1
	if bit_a == '0' and bit_b == '1':
		cnt_2 += 1
	if bit_a == '1' and bit_b == '1':
		cnt_3 += 1
	if bit_a == '0' and bit_b == '0':
		cnt_4 += 1
print(cnt_1 * cnt_2 + cnt_1 * cnt_4 + cnt_4 * cnt_3)


n = int(input())
a = list(map(int, list(input())))
b = list(map(int, list(input())))
zerzero = 0
zerone = 0
onezero = 0
oneone = 0
for i in range(n):
	if a[i] + b[i] == 0:
		zerzero += 1
	elif a[i] + b[i] == 2:
		oneone += 1
	elif a[i] == 0:
		zerone += 1
	else:
		onezero += 1
ans = zerzero * oneone + onezero * (zerone + zerzero)
print(ans)


from sys import stdin
from functools import reduce, cmp_to_key

def main():
	n = int(stdin.readline().strip())
	a = stdin.readline().strip()
	b = stdin.readline().strip()
	pairs = {}
	candidates_1 = 0
	candidates_0 = 0
	total = 0
	ones = 0
	ceros = 0
	for i in range(n):
		if a[i] == '1':
			total += candidates_0
			ones += 1
		else:
			ceros += 1
			total += candidates_1
		if a[i] == '0' and b[i] == '0' or (a[i] == '1' and b[i] == '0'):
			if a[i] == '0':
				total += ones - candidates_1
				candidates_0 += 1
			else:
				total += ceros - candidates_0
				candidates_1 += 1
	print(total)
main()


n = int(input())
a = input()
b = input()
a00 = 0
a11 = 0
a01 = 0
a10 = 0
for i in range(n):
	if a[i] == '0' and b[i] == '0':
		a00 += 1
	elif a[i] == '1' and b[i] == '1':
		a11 += 1
	elif a[i] == '0' and b[i] == '1':
		a01 += 1
	elif a[i] == '1' and b[i] == '0':
		a10 += 1
print(a00 * a11 + a01 * a10 + a10 * a00)


str_len = int(input())
str_a = input()
str_b = input()
table_list = list()
for i in range(str_len):
	table_dict = dict()
	table_dict['00'] = 0
	table_dict['01'] = 0
	table_dict['10'] = 0
	table_dict['11'] = 0
	char_a = str_a[i]
	char_b = str_b[i]
	key_str = char_a + char_b
	if i == 0:
		table_dict[key_str] = 1
	else:
		for key in table_dict.keys():
			if key == key_str:
				table_dict[key] = 1 + table_list[i - 1][key]
			else:
				table_dict[key] = table_list[i - 1][key]
	table_list.append(table_dict)
ans = 0
for char_idx in range(str_len):
	if char_idx == 0:
		continue
	else:
		char_a = str_a[char_idx]
		char_b = str_b[char_idx]
		if char_a == '0' and char_b == '0':
			ans = ans + table_list[char_idx - 1]['10'] + table_list[char_idx - 1]['11']
		elif char_a == '0' and char_b == '1':
			ans = ans + table_list[char_idx - 1]['10']
		elif char_a == '1' and char_b == '0':
			ans = ans + table_list[char_idx - 1]['00'] + table_list[char_idx - 1]['01']
		else:
			ans = ans + table_list[char_idx - 1]['00']
print(ans)


n = int(input())
a = input()
b = input()
zerozero = 0
oneone = 0
onezero = 0
zeroone = 0
for i in range(n):
	if a[i] == '0' and b[i] == '0':
		zerozero += 1
		continue
	if a[i] == '1' and b[i] == '1':
		oneone += 1
		continue
	if a[i] == '0':
		zeroone += 1
		continue
	if a[i] == '1':
		onezero += 1
		continue
ans = 0
ans += zerozero * (onezero + oneone) + zeroone * onezero
print(ans)


n = int(input())
a = input()
b = input()
swap = 0
k1 = a.count('1')
k2 = a.count('0')
for i in range(n):
	if b[i] == '0':
		if a[i] == '0':
			swap += k1
			k2 -= 1
		else:
			swap += k2
			k1 -= 1
print(swap)


n = int(input())
a = input()
b = input()
c = a.count('0')
zero_one = 0
one_one = 0
zero_zero = 0
for i in range(n):
	if a[i] == '0' and b[i] == '0':
		zero_zero += 1
	elif a[i] == '1' and b[i] == '0':
		zero_one += 1
	elif a[i] == '1' and b[i] == '1':
		one_one += 1
print(c * zero_one + zero_zero * one_one)


n = int(input())
a = input()
b = input()
n00 = 0
n01 = 0
n10 = 0
n11 = 0
for i in range(n):
	if a[i] == '0' and b[i] == '0':
		n00 += 1
	elif a[i] == '0' and b[i] == '1':
		n01 += 1
	elif a[i] == '1' and b[i] == '0':
		n10 += 1
	else:
		n11 += 1
ans = 0
for i in range(n):
	if a[i] == '0' and b[i] == '0':
		ans += n11 + n10
	elif a[i] == '0' and b[i] == '1':
		ans += n10
	elif a[i] == '1' and b[i] == '0':
		ans += n00 + n01
	else:
		ans += n00
print(int(ans / 2))


n = int(input())
a = input()
b = input()
x1 = 0
x2 = 0
x3 = 0
x4 = 0
for i in range(0, n):
	a1 = a[i]
	b1 = b[i]
	if a1 == '0' and b1 == '0':
		x1 = x1 + 1
	if a1 == '1' and b1 == '0':
		x2 = x2 + 1
	if a1 == '0' and b1 == '1':
		x3 = x3 + 1
	if a1 == '1' and b1 == '1':
		x4 = x4 + 1
out = x1 * x2 + x2 * x3 + x4 * x1
print(str(out))


n = int(input())
a = str(input())
b = str(input())
a = list(a)
b = list(b)
for i in range(len(a)):
	a[i] = int(a[i])
	b[i] = int(b[i])
d0 = 0
d1 = 0
c0 = a.count(0)
c1 = a.count(1)
for i in range(len(b)):
	if b[i] == 0:
		if a[i] == 0:
			d0 += 1
		else:
			d1 += 1
print(d0 * c1 + d1 * c0 - d0 * d1)


from math import factorial as fac
n = int(input())
a = input()
b = input()
score = 0
lo = 0
ol = 0
ll = 0
oo = 0
for i in range(len(a)):
	if a[i] == '1':
		if b[i] == '0':
			lo += 1
		else:
			ll += 1
	elif b[i] == '0':
		oo += 1
	else:
		ol += 1
score += lo * ol
score += oo * ll
score += oo * lo
print(score)


n = int(input())
s1 = input().strip()
s2 = input().strip()
zero = s1.count('0')
one = s1.count('1')
ans = 0
for i in range(n):
	if s2[i] == '0':
		if s1[i] == '0':
			ans += one
		else:
			ans += zero
z_zero = 0
z_one = 0
for i in range(n):
	if s2[i] == '0':
		if s1[i] == '0':
			z_zero += 1
		else:
			z_one += 1
print(ans - z_zero * z_one)


m = list(map(int, input().split()))[0]
a = input()
b = input()
multipliers = {'00': 0, '01': 0, '10': 0, '11': 0}
matches = {'00': ['10', '11'], '01': ['10'], '10': ['00', '01'], '11': ['00']}
counter = 0
for i in range(m):
	look_up = f'{a[i]}{b[i]}'
	for match in matches[look_up]:
		counter += multipliers[match]
	multipliers[look_up] += 1
print(int(counter))


n = int(input())
A = list(input())
B = list(input())
m = 0
k = 0
for elem in A:
	if elem == '0':
		m += 1
	if elem == '1':
		k += 1
p = 0
q = 0
for i in range(len(A)):
	if A[i] == '0' and B[i] == '1':
		p += 1
	if A[i] == '1' and B[i] == '1':
		q += 1
print(k * m - p * q)


n = input()
a = input()
b = input()
c0 = [i for i in range(len(a)) if a[i] == '0' and b[i] == '1']
c1 = [i for i in range(len(a)) if a[i] == '1' and b[i] == '1']
c = len(c0) * len(c1)
print(a.count('0') * a.count('1') - c)


n = int(input())
a = input()
b = input()
state = {'00': 0, '01': 0, '10': 0, '11': 0}
for (i, j) in zip(a, b):
	state[i + j] += 1
print(state['00'] * state['10'] + state['00'] * state['11'] + state['01'] * state['10'])


pairs = [0, 0, 0, 0]
n = int(input())
a = input()
b = input()
for i in range(n):
	if a[i] == '0' and b[i] == '0':
		pairs[0] += 1
	elif a[i] == '0' and b[i] == '1':
		pairs[1] += 1
	elif a[i] == '1' and b[i] == '0':
		pairs[2] += 1
	elif a[i] == '1' and b[i] == '1':
		pairs[3] += 1
total = total_00 = pairs[0] * pairs[2] + pairs[0] * pairs[3] + pairs[2] * pairs[1]
print(total)


from collections import defaultdict
(n, a, b) = (int(input()), input(), input())
cnt = defaultdict(int)
for i in range(n):
	cnt[a[i] + b[i]] += 1
print(cnt['00'] * cnt['11'] + cnt['10'] * (cnt['00'] + cnt['01']))


n = int(input())
a = [int(x) for x in input()]
b = [int(x) for x in input()]
cont1 = 0
cont0 = 0
tot = 0
comb0 = 0
comb1 = 0
for x in range(n):
	if a[x] == 0:
		cont0 += 1
	else:
		cont1 += 1
for x in range(n):
	if b[x] == 0:
		if a[x] == 0:
			tot += cont1 - comb1
			comb0 += 1
		else:
			tot += cont0 - comb0
			comb1 += 1
print(tot)


from sys import stdin, stdout
from collections import Counter
import math
I = lambda : map(int, stdin.readline().split())
I1 = lambda : stdin.readline()
n = int(I1())
(a, b) = (I1(), I1())
(s1, s0, d1, d0) = (0, 0, 0, 0)
for i in range(n):
	if b[i] == '0':
		if a[i] == '1':
			d1 += 1
		else:
			d0 += 1
	elif a[i] == '1':
		s1 += 1
	else:
		s0 += 1
print(s0 * d1 + s1 * d0 + d0 * d1)


n = int(input())
a = input()
b = input()
zeros_a = list(a).count('0')
zeros_b = []
ones_a = list(a).count('1')
count = 0
for i in range(len(b)):
	if b[i] == '0':
		if a[i] == '0':
			count += ones_a
			zeros_a -= 1
		else:
			count += zeros_a
			ones_a -= 1
print(count)


from sys import stdin, stdout
n = int(input())
a = input()
b = input()
cnts = {'00': 0, '11': 0, '01': 0, '10': 0}
for i in range(n):
	cnts[a[i] + b[i]] += 1
swaps = 0
for i in range(n - 1):
	if a[i] == '0' and b[i] == '0':
		cnts['00'] -= 1
		swaps += cnts['10'] + cnts['11']
	elif a[i] == '1' and b[i] == '1':
		cnts['11'] -= 1
		swaps += cnts['00']
	elif a[i] == '0' and b[i] == '1':
		cnts['01'] -= 1
		swaps += cnts['10']
	else:
		cnts['10'] -= 1
		swaps += cnts['01'] + cnts['00']
print(swaps)


n = int(input())
a = list(map(int, list(input())))
b = list(map(int, list(input())))
a0 = 0
a1 = 0
ans = 0
b0 = 0
b1 = 0
for i in a:
	if i == 0:
		a0 += 1
	else:
		a1 += 1
for i in range(n):
	if b[i] == 0:
		if a[i] == 0:
			ans += a1
			b0 += 1
		else:
			ans += a0
			b1 += 1
ans -= b0 * b1
print(ans)


n = int(input())
s = input()
t = input()
ans = 0
cnt = 0
cnt1 = 0
s1 = s.count('1')
s0 = s.count('0')
t1 = t.count('1')
t0 = t.count('0')
for i in range(len(t)):
	if s1 == n or t1 == n:
		break
	if t[i] == '0':
		if s[i] == '0':
			ans += s1 - cnt1
			cnt += 1
		else:
			ans += s0 - cnt
			cnt1 += 1
print(ans)


n = int(input())
s1 = input()
s2 = input()
c = 0
for i in range(0, n):
	if s1[i] == '0':
		c += 1
c2 = 0
c3 = 0
c4 = 0
for i in range(0, n):
	if s1[i] == '0' and s2[i] == '0':
		c2 += 1
	elif s1[i] == '1' and s2[i] == '0':
		c3 += 1
	elif s1[i] == '1' and s2[i] == '1':
		c4 += 1
s = c * c3 + c2 * c4
print(s)


def main():
	N = int(input())
	A = input()
	B = input()
	d = {(0, 0): 0, (0, 1): 0, (1, 0): 0, (1, 1): 0}
	c = 0
	for i in range(N):
		a = int(A[i])
		b = int(B[i])
		c += d[a, b]
		if (a, b) == (0, 0):
			d[1, 0] += 1
			d[1, 1] += 1
		elif (a, b) == (0, 1):
			d[1, 0] += 1
		elif (a, b) == (1, 0):
			d[0, 0] += 1
			d[0, 1] += 1
		else:
			d[0, 0] += 1
	print(c)
main()


def solution():
	input()
	a = input()
	b = input()
	zero_count = a.count('0')
	one_count = a.count('1')
	ans = 0
	for (idx, dig) in enumerate(b):
		if dig == '1':
			continue
		if a[idx] == '1':
			ans += zero_count
			one_count -= 1
		else:
			ans += one_count
			zero_count -= 1
	print(ans)
solution()


n = int(input())
a = input()
b = input()
c_0 = a.count('0')
c_1 = a.count('1')
c_00 = 0
for i in range(n):
	if a[i] == b[i] == '0':
		c_00 += 1
res = 0
for i in range(n):
	if a[i] == b[i] == '0':
		res += c_1
	elif a[i] == '1' and b[i] == '0':
		res += c_0 - c_00
print(res)


N = int(input())
A = list(map(int, input()))
B = list(map(int, input()))
s = 0
Z = A.count(0)
O = A.count(1)
L = set([])
for i in range(N - 1, -1, -1):
	if B[i] == 0:
		if A[i] == 1:
			s += Z
			O -= 1
		if A[i] == 0:
			s += O
			Z -= 1
print(s)


n = int(input())
a = str(input())
b = str(input())
(k1, k2, k3, k4) = (0, 0, 0, 0)
for i in range(n):
	if int(a[i]) == 1 and int(b[i]) == 0:
		k1 += 1
	elif int(a[i]) == 0 and int(b[i]) == 1:
		k2 += 1
	elif int(a[i]) == 0 and int(b[i]) == 0:
		k3 += 1
	else:
		k4 += 1
s = k1 * k2 + k3 * k4 + k3 * k1
print(s)


USE_STDIO = False
if not USE_STDIO:
	try:
		import mypc
	except:
		pass

def main():
	(n,) = list(map(int, input().split(' ')))
	a = [x for x in map(int, input())]
	b = [x for x in map(int, input())]
	cnts = [0, 0, 0, 0]
	for (x, y) in zip(a, b):
		cnts[x * 2 + y] += 1
	ans = cnts[0] * cnts[3] + cnts[1] * cnts[2] + cnts[0] * cnts[2]
	print(ans)

def __starting_point():
	main()
__starting_point()


n = int(input())
a = input()
b = input()
k1 = 0
k2 = 0
k3 = 0
k4 = 0
k5 = 0
k6 = 0
for i in range(n):
	if a[i] == '1' and b[i] == '1':
		k1 += 1
	if a[i] == '0' and b[i] == '1':
		k2 += 1
	if a[i] == '1' and b[i] == '0':
		k3 += 1
	if a[i] == '0' and b[i] == '0':
		k4 += 1
print(k3 * k2 + k4 * k1 + k3 * k4)


n = int(input())
n1 = list(input())
n2 = list(input())
count1 = n1.count('1')
count0 = n1.count('0')
t = 0
x = 0
one_zero_pair = 0
for i in range(n):
	if n1[i] == '1' and n2[i] == '0':
		t += count0
		one_zero_pair += 1
	elif n1[i] == '0' and n2[i] == '0':
		t += count1
		x += 1
print(t - x * one_zero_pair)


I = lambda : map(int, input().split())
n = int(input())
a = list(input())
b = list(input())
c1 = a.count('1')
c0 = a.count('0')
an = 0
for j in range(n):
	if b[j] == '0':
		if a[j] == '1' and c0 > 0:
			an += c0
			c1 -= 1
		elif a[j] == '0' and c1 > 0:
			an += c1
			c0 -= 1
print(an)


n = int(input())
a = input()
b = input()
l = [0] * n
cnt1 = 0
cnt10 = 0
cnt00 = 0
cnt01 = 0
for i in range(n):
	if a[i] == '1':
		cnt1 += 1
		if b[i] == '0':
			cnt10 += 1
	elif b[i] == '0':
		cnt00 += 1
	else:
		cnt01 += 1
print(cnt00 * cnt1 + cnt01 * cnt10)


F = lambda : list(map(int, input()))
n = int(input())
a = F()
b = F()
(x, y) = (a.count(0), a.count(1))
p = sorted(list(zip(a, b, range(n))), key=lambda x: x[1])[:b.count(0)]
count0 = len(list(filter(lambda n: n[0] == 0, p)))
count1 = len(p) - count0
print(count0 * y + count1 * x - count0 * count1)


n = int(input())
a = input()
b = input()
X = [None] * n
if a[0] == '0':
	X[0] = (1, 0)
else:
	X[0] = (0, 1)
for i in range(1, n):
	if a[i] == '0':
		X[i] = (X[i - 1][0] + 1, X[i - 1][1])
	else:
		X[i] = (X[i - 1][0], X[i - 1][1] + 1)
Y = [None] * n
if b[0] == '1':
	Y[0] = (0, 0)
elif a[0] == '0':
	Y[0] = (1, 0)
else:
	Y[0] = (0, 1)
for i in range(1, n):
	if b[i] == '0':
		if a[i] == '0':
			Y[i] = (Y[i - 1][0] + 1, Y[i - 1][1])
		else:
			Y[i] = (Y[i - 1][0], Y[i - 1][1] + 1)
	else:
		Y[i] = (Y[i - 1][0], Y[i - 1][1])
ANS = 0
for i in range(n - 1, 0, -1):
	if b[i] == '0':
		if a[i] == '0':
			ANS += X[i - 1][1]
		elif a[i] == '1':
			ANS += X[i - 1][0]
	elif a[i] == '0':
		ANS += Y[i - 1][1]
	elif a[i] == '1':
		ANS += Y[i - 1][0]
print(ANS)


n = int(input())
a = input()
b = input()
z = a.count('0')
z1 = b.count('0')
ans = 0
tot = 0
for i in range(n):
	if b[i] == '0' and a[i] == '0':
		ans = ans + (len(a) - z)
		tot = tot + 1
ans = ans + (z1 - tot) * (z - tot)
print(ans)


import sys
n = int(input())
A = input()
B = input()
counter = [[0, 0], [0, 0]]
for i in range(n):
	a = ord(A[i]) - 48
	b = ord(B[i]) - 48
	counter[a][b] += 1
res = 0
for a in range(2):
	for b in range(2):
		for c in range(2):
			for d in range(2):
				(v1, v2) = (a | b, c | d)
				(v3, v4) = (c | b, a | d)
				if v1 != v3 or v2 != v4:
					res += counter[a][b] * counter[c][d]
print(res // 2)


mod = 10 ** 9 + 7
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())
import math
n = ii()
s1 = si()
s2 = si()
(a0, a1, b0, b1) = (0, 0, 0, 0)
for i in range(n):
	if s2[i] == '0':
		if s1[i] == '1':
			a1 += 1
		else:
			a0 += 1
	elif s1[i] == '1':
		b1 += 1
	else:
		b0 += 1
print(a0 * b1 + a1 * b0 + a0 * a1)


count = int(input())
a = input()
b = input()
a0 = 0
a1 = 0
sum = 0
for i in range(count):
	if int(a[i]) == 1:
		a1 += 1
	elif int(b[i]) != 0:
		a0 += 1
for i in range(count):
	if int(b[i]) == 0:
		if int(a[i]) == 0:
			sum += a1
		else:
			sum += a0
print(sum)


t = int(input())
a = input()
b = input()
aOnes = a.count('1')
aOneswithZeros = 0
for i in range(t):
	if a[i] == '1' and b[i] == '0':
		aOneswithZeros += 1
ans = 0
for i in range(t):
	if a[i] == '0' and b[i] == '0':
		ans += aOnes
	if a[i] == '0' and b[i] == '1':
		ans += aOneswithZeros
print(ans)


def read():
	return int(input())

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

def readmap():
	return map(int, input().split())
n = read()
a = input()
b = input()
a_1 = []
for i in range(n):
	if b[i] == '1':
		a_1.append(a[i])
num0 = a.count('0')
num1 = a.count('1')
num0_1 = a_1.count('0')
num1_1 = a_1.count('1')
print(num0 * num1 - num0_1 * num1_1)


import sys
lines = sys.stdin.readlines()
n = int(lines[0])
a = lines[1]
b = lines[2]
d = {'00': 0, '01': 0, '10': 0, '11': 0}
for i in range(n):
	d[a[i] + b[i]] += 1
print(d['00'] * (d['10'] + d['11']) + d['10'] * d['01'])


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from heapq import *
from copy import deepcopy
from collections import deque
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
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))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 10 ** 9 + 7

def inp():
	return sys.stdin.readline().rstrip('\r\n')

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

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

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for pp in range(t):
		solve(pp)

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def google(p):
	print('Case #' + str(p) + ': ', end='')

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

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 ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

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

def solve(case):
	n = int(inp())
	a = list(inp())
	b = list(inp())
	for i in range(n):
		a[i] = int(a[i])
		b[i] = int(b[i])
	pre1 = [0] * (n + 1)
	pre1temp = [0] * (n + 1)
	prekharab1 = [0] * (n + 1)
	for i in range(n - 1, -1, -1):
		pre1[i] = pre1[i + 1] + a[i]
		if b[i] == 0:
			pre1temp[i] = pre1temp[i + 1] + 1
		else:
			pre1temp[i] = pre1temp[i + 1]
		if b[i] == 0 and a[i] == 1:
			prekharab1[i] = prekharab1[i + 1] + 1
		else:
			prekharab1[i] = prekharab1[i + 1]
	ans = 0
	for i in range(n):
		if b[i] == 0:
			if a[i] == 0:
				ans += pre1[i + 1]
			else:
				ans += n - 1 - i - pre1[i + 1]
		elif a[i] == 0:
			ans += prekharab1[i + 1]
		else:
			ans += pre1temp[i + 1] - prekharab1[i + 1]
	print(ans)
testcase(1)


n = int(input())
a = input()
b = input()
c00 = 0
c01 = 0
c10 = 0
c11 = 0
for (ai, bi) in zip(a, b):
	if ai == '0' and bi == '0':
		c00 += 1
	elif ai == '0' and bi == '1':
		c01 += 1
	elif ai == '1' and bi == '0':
		c10 += 1
	else:
		c11 += 1
print(c10 * c01 + c00 * (c10 + c11))


def main():
	(n, c) = (int(input()), [0] * 4)
	for (a, b) in zip(*(map(int, input()) for _ in 'ab')):
		c[a + b * 2] += 1
	print(c[1] * (c[0] + c[2]) + c[3] * c[0])
main()


n = int(input())
a = input()
b = input()
t0 = 0
t1 = 0
t2 = 0
t3 = 0
for i in range(n):
	if a[i] == '0':
		if b[i] == '0':
			t0 += 1
		else:
			t1 += 1
	elif b[i] == '0':
		t2 += 1
	else:
		t3 += 1
print(t0 * t3 + t1 * t2 + t2 * t0)


n = int(input())
(a, b) = ([*map(int, list(input()))], [*map(int, list(input()))])
changed = [False] * n
for i in range(n):
	if b[i] == 0:
		changed[i] = True
stateCnt = [0] * 4
for i in range(n):
	if a[i] == 1 and changed[i] == True:
		stateCnt[0] += 1
	elif a[i] == 1 and changed[i] == False:
		stateCnt[1] += 1
	elif a[i] == 0 and changed[i] == True:
		stateCnt[2] += 1
	else:
		stateCnt[3] += 1
print(stateCnt[0] * stateCnt[2] + stateCnt[0] * stateCnt[3] + stateCnt[2] * stateCnt[1])


n = int(input())
a = int(input(), 2)
b = int(input(), 2)
c = str(bin(a | b))[2:].zfill(n)
a = str(bin(a))[2:].zfill(n)
b = str(bin(b))[2:].zfill(n)
print(c.count('0') * a.count('1') + (b.count('0') - c.count('0')) * (a.count('0') - c.count('0')))


n = int(input())
a = list(map(int, input()))
b = list(map(int, input()))
mp = {}
ans = 0
for i in zip(a, b):
	for j in mp:
		if j[0] != i[0] and i[-1] == 0:
			ans += mp[j]
		elif i[-1] == 1 and j[-1] == 0 and (j[0] != i[0]):
			ans += mp[j]
	if i not in mp:
		mp[i] = 1
	else:
		mp[i] += 1
print(ans)


n = int(input())
a = list(map(int, list(input())))
b = list(map(int, list(input())))
c10 = 0
c01 = 0
c00 = 0
c11 = 0
for i in range(n):
	tmp = [a[i], b[i]]
	if tmp == [1, 0]:
		c10 += 1
	elif tmp == [0, 1]:
		c01 += 1
	elif tmp == [0, 0]:
		c00 += 1
	else:
		c11 += 1
ans = c10 * c01 + c10 * c00 + c11 * c00
print(ans)


I = input
I()
x = zeros = ones = zeros_0 = ones_0 = 0
for (a, b) in zip(I(), I()):
	if b == '0':
		if a == '0':
			x += ones
			zeros += 1
			zeros_0 += 1
		else:
			x += zeros
			ones += 1
			ones_0 += 1
	elif a == '0':
		x += ones_0
		zeros += 1
	else:
		x += zeros_0
		ones += 1
print(x)


def number_of_ways(a, b):
	num_1 = 0
	for (i, digit) in enumerate(b):
		if a[i] == '1' and digit == '1':
			num_1 += 1
	num_0 = a.count('0')
	total_ways = 0
	for (i, digit) in enumerate(b):
		if digit == '1':
			continue
		if a[i] == '0':
			total_ways += num_1
		else:
			total_ways += num_0
	return total_ways
num_bits = input()
bitstring_a = input()
bitstring_b = input()
print(number_of_ways(bitstring_a, bitstring_b))


n = int(input())
a = input()
b = input()
t1 = t2 = t3 = t4 = 0
for i in range(n):
	if a[i] == b[i] == '0':
		t1 += 1
	if (a[i] == '1') & (b[i] == '0'):
		t2 += 1
	if a[i] == b[i] == '1':
		t3 += 1
	if (a[i] == '0') & (b[i] == '1'):
		t4 += 1
ans = t1 * t2 + t1 * t3 + t2 * t4
print(ans)


n = int(input())
a = input()
b = input()
first = []
second = []
for i in a:
	first.append(int(i))
for i in b:
	second.append(int(i))
os = [0] * 4
for i in range(n):
	if first[i] == 0:
		if second[i] == 0:
			os[0] += 1
		else:
			os[1] += 1
	elif second[i] == 0:
		os[2] += 1
	else:
		os[3] += 1
ans = 0
ans += os[0] * (os[2] + os[3])
ans += os[1] * os[2]
print(ans)


from sys import stdin, stdout
n = int(stdin.readline())
x = stdin.readline().strip()
y = stdin.readline().strip()
a = b = c = d = 0
for i in range(n):
	if y[i] == '0':
		if x[i] == '0':
			c += 1
		else:
			d += 1
	elif x[i] == '0':
		a += 1
	else:
		b += 1
print(a * d + b * c + c * d)


n = int(input())
a = input()
b = input()
a0 = sum([v == '0' for v in a])
a1 = sum([v == '1' for v in a])
c = [a[i] == '1' and b[i] == '0' for i in range(n)]
re = sum(c)
ans = 0
for (i, v) in enumerate(b):
	if v == '0':
		if a[i] == '1':
			ans += a0
		else:
			ans += a1
			ans -= re
print(ans)


n = int(input())
a = input()
b = input()
c00 = 0
c10 = 0
c0 = 0
for i in range(n):
	if a[i] == '1' and b[i] == '0':
		c10 += 1
	elif a[i] == '0' and b[i] == '0':
		c00 += 1
	if a[i] == '0':
		c0 += 1
c1 = n - c0
print(c00 * c1 + c10 * c0 - c00 * c10)


n = int(input())
a = input()
b = input()
zer = 0
one = 0
ta = a.count('1')
tz = a.count('0')
for i in range(n):
	if a[i] == '0' and b[i] == '0':
		zer += 1
	elif a[i] == '1' and b[i] == '0':
		one += 1
ans = zer * ta + one * tz - zer * one
print(ans)


amount = int(input())
first_array = [int(s) for s in input()]
second_array = [int(s) for s in input()]
array_of_1 = []
array_of_0 = []
amount_1 = sum(first_array)
amount_0 = len(first_array) - amount_1
counter = 0
counter_00 = 0
counter_10 = 0
for i in range(len(first_array)):
	if first_array[i] == 0 and second_array[i] == 0:
		counter += amount_1
		counter_00 += 1
	elif first_array[i] == 1 and second_array[i] == 0:
		counter += amount_0
		counter_10 += 1
print(counter - counter_00 * counter_10)


n = int(input())
a = list(map(int, str(input())))
b = list(map(int, str(input())))
count00 = 0
count10 = 0
count01 = 0
count1 = 0
count11 = 0
for i in range(n):
	if a[i] == 1:
		count1 += 1
	if a[i] == 1 and b[i] == 1:
		count11 += 1
	elif a[i] == 0 and b[i] == 1:
		count01 += 1
	elif a[i] == 1 and b[i] == 0:
		count10 += 1
	elif a[i] == 0 and b[i] == 0:
		count00 += 1
print(count00 * count1 + count10 * count01)


n = int(input())
a = input()
b = input()
kind0 = 0
kind1 = 0
kind2 = 0
kind3 = 0
for i in range(n):
	if a[i] == '0' and b[i] == '0':
		kind0 += 1
	elif a[i] == '0' and b[i] == '1':
		kind1 += 1
	elif a[i] == '1' and b[i] == '0':
		kind2 += 1
	else:
		kind3 += 1
print(kind0 * kind2 + kind0 * kind3 + kind1 * kind2)


n = int(input())
a = input()
b = input()
z = 0
o = 0
(cz, co) = (0, 0)
for i in range(n):
	if b[i] == '0':
		if a[i] == '0':
			cz += 1
		else:
			co += 1
	if a[i] == '0':
		z += 1
	else:
		o += 1
print(cz * o + co * z - co * cz)


n = int(input())
s1 = input()
s2 = input()
a = [0] * 10
for i in range(n):
	if s1[i] == '0':
		if s2[i] == '0':
			a[1] += 1
		else:
			a[2] += 1
	elif s2[i] == '1':
		a[3] += 1
	else:
		a[4] += 1
ans = a[2] * a[4] + a[1] * a[3] + a[1] * a[4]
print(ans)


n = int(input())
x = input()
y = input()
xl = [int(i) for i in x]
yl = [int(i) for i in y]
c1 = 0
c2 = 0
cnt1 = xl.count(1)
cnt0 = xl.count(0)
for i in range(n):
	if x[i] == '0' and y[i] == '0':
		c1 += 1
	elif x[i] == '1' and y[i] == '0':
		c2 += 1
cnt1 -= c2
print(c1 * cnt1 + c2 * cnt0)


n = int(input())
a = input()
b = input()
cnt00 = 0
cnt01 = 0
cnt10 = 0
cnt11 = 0
for i in range(n):
	if a[i] == '0' and b[i] == '0':
		cnt00 += 1
	if a[i] == '0' and b[i] == '1':
		cnt01 += 1
	if a[i] == '1' and b[i] == '0':
		cnt10 += 1
	if a[i] == '1' and b[i] == '1':
		cnt11 += 1
ans = cnt01 * cnt10 + cnt10 * cnt00 + cnt11 * cnt00
print(ans)


n = int(input())
a = input()
b = input()
ones_a2 = 0
zeroes_a2 = 0
for i in range(n):
	if b[i] == '1':
		if a[i] == '0':
			zeroes_a2 += 1
		else:
			ones_a2 += 1
ones_a = 0
zeroes_a = 0
answer = 0
for i in range(n):
	if b[i] == '0':
		answer += ones_a + ones_a2 if a[i] == '0' else zeroes_a + zeroes_a2
		if a[i] == '0':
			zeroes_a += 1
		else:
			ones_a += 1
print(answer)


num = int(input())
b1 = input()
b2 = input()
case_dict = {'00': 0, '01': 1, '10': 2, '11': 3}
case = [0] * 4
for i in range(num):
	case[case_dict[b1[i] + b2[i]]] += 1
print(case[0] * (case[2] + case[3]) + case[2] * case[1])


n = int(input())
s1 = input()
s2 = input()
(c11, c10, c01, c00) = (0, 0, 0, 0)
for i in range(n):
	if s1[i] == '1' and s2[i] == '1':
		c11 += 1
	elif s1[i] == '1' and s2[i] == '0':
		c10 += 1
	elif s1[i] == '0' and s2[i] == '1':
		c01 += 1
	elif s1[i] == '0' and s2[i] == '0':
		c00 += 1
print((c11 + c10) * c00 + c10 * c01)


n = int(input())
a = list(input())
b = list(input())
mat = [[0, 0], [0, 0]]
for i in range(n):
	if a[i] == '0' and b[i] == '0':
		mat[0][0] += 1
	elif a[i] == '0' and b[i] == '1':
		mat[0][1] += 1
	elif a[i] == '1' and b[i] == '0':
		mat[1][0] += 1
	elif a[i] == '1' and b[i] == '1':
		mat[1][1] += 1
print(mat[0][0] * sum(mat[1]) + mat[1][0] * mat[0][1])


n = int(input())
a = input()
b = input()
ans = 0
a1 = 0
a0 = 0
for i in a:
	if i == '1':
		a1 += 1
	else:
		a0 += 1
b1 = 0
b0 = 0
for (k, i) in enumerate(b):
	if i == '1':
		if a[k] == '1':
			b1 += 1
		else:
			b0 += 1
ans = a0 * a1 - b0 * b1
print(ans)


def getBits(n, a, b):
	if '0' not in a or '1' not in a or '0' not in b:
		return 0
	(visited0, visited1) = (0, 0)
	swaps = 0
	num0a = a.count('0')
	num1a = a.count('1')
	for i in range(n):
		if b[i] == '0':
			if a[i] == '0':
				visited0 += 1
				swaps += num1a - visited1
			else:
				visited1 += 1
				swaps += num0a - visited0
	return swaps
n = int(input())
a = input()
b = input()
print(getBits(n, a, b))


def mmhaxor(n, a, b):
	d = {('0', '0'): 0, ('0', '1'): 0, ('1', '0'): 0, ('1', '1'): 0}
	for i in range(n):
		d[a[i], b[i]] += 1
	print(d['0', '0'] * d['1', '0'] + d['0', '0'] * d['1', '1'] + d['0', '1'] * d['1', '0'])
n = int(input())
a = input()
b = input()
mmhaxor(n, a, b)


import sys

def input():
	return sys.stdin.readline().strip()
n = int(input())
a = input()
b = input()
zeros = [i for i in range(n) if a[i] == '0']
ones = [i for i in range(n) if a[i] == '1']
same = [b[i] == '1' for i in range(n)]
samezeros = [i for i in zeros if same[i]]
sameones = [i for i in ones if same[i]]
ans = len(zeros) * len(ones) - len(samezeros) * len(sameones)
print(ans)


n_raw = input()
a = input()
b = input()
n = int(n_raw)
ones_in_a = 0
ones_in_both = 0
z = zip(a, b)
zeros_in_a = 0
zeros_only_in_a = 0
for (ai, bi) in z:
	if ai == '1':
		if bi == '1':
			ones_in_both += 1
		ones_in_a += 1
	else:
		if bi == '1':
			zeros_only_in_a += 1
		zeros_in_a += 1
print(ones_in_a * zeros_in_a - ones_in_both * zeros_only_in_a)


input()
b = list(map(lambda x: int(''.join(x), 2), zip(input(), input())))
p = [b.count(k) for k in range(4)]
print(p[0] * (p[2] + p[3]) + p[1] * p[2])


n = int(input())
a = input()
b = input()
xx = 0
xy = 0
yx = 0
yy = 0
for i in range(n):
	if a[i] == '1' and b[i] == '1':
		xx += 1
	elif a[i] == '1' and b[i] == '0':
		xy += 1
	elif a[i] == '0' and b[i] == '1':
		yx += 1
	elif a[i] == '0' and b[i] == '0':
		yy += 1
print(xx * yy + xy * yx + yy * xy)


i = int(input())
la = list(map(int, list(input())))
lb = list(map(int, list(input())))
a = b = c = d = 0
for x in range(i):
	if lb[x] == 1:
		if la[x] == 0:
			a += 1
		else:
			b += 1
	elif la[x] == 0:
		c += 1
	else:
		d += 1
print(c * b + d * a + c * d)


import sys
data = sys.stdin.readlines()
n = int(data[0])
a = data[1].strip()
b = data[2].strip()
count = 0
one = a.count('1')
zero = len(a) - one
for i in range(n):
	if b[i] == '0':
		if a[i] == '0':
			count += one
			zero -= 1
		else:
			count += zero
			one -= 1
print(count)


input()
a = input()
b = input()
count_a_1 = 0
count_01 = 0
for i in range(len(a)):
	if a[i] == '1':
		count_a_1 += 1
	if a[i] == '0' and b[i] == '1':
		count_01 += 1
r = 0
for i in range(len(a)):
	if b[i] == '0':
		if a[i] == '0':
			r += count_a_1
		else:
			r += count_01
print(r)


n = int(input())
a = list(map(int, input()))
b = list(map(int, input()))
zz = 0
zo = 0
oz = 0
oo = 0
for (x, y) in zip(a, b):
	if (x, y) == (0, 0):
		zz += 1
	elif (x, y) == (1, 0):
		oz += 1
	elif (x, y) == (0, 1):
		zo += 1
	else:
		oo += 1
print(zz * (oo + oz) + zo * oz)


def solve(s1, s2, n):
	a = b = c = d = 0
	ans = 0
	for i in range(n):
		if s1[i] == '1':
			if s2[i] == '1':
				a += 1
			else:
				b += 1
		elif s2[i] == '0':
			c += 1
		else:
			d += 1
	ans = a * c + d * b + c * b
	return ans
n = int(input())
s1 = input()
s2 = input()
print(solve(s1, s2, n))


def main():
	n = int(input())
	a = [int(ch) for ch in input()]
	b = [int(ch) for ch in input()]
	c = [[0, 0], [0, 0]]
	for i in range(n):
		c[a[i]][b[i]] += 1
	ans = c[0][0] * c[1][0] + c[1][1] * c[0][0] + c[0][1] * c[1][0]
	print(ans)
exit(main())


n = int(input())
a = input()
b = input()
zero = [0, 0]
one = [0, 0]
for i in range(n):
	if b[i] == '0':
		if a[i] == '0':
			zero[0] += 1
		else:
			one[0] += 1
	elif b[i] == '1':
		if a[i] == '0':
			zero[1] += 1
		else:
			one[1] += 1
print(zero[0] * one[0] + zero[0] * one[1] + zero[1] * one[0])


from collections import Counter
n = int(input())
a = list(map(int, input()))
b = list(map(int, input()))
ways = 0
l = Counter(a)
ones = int(l[1])
j = 0
zeros = 0
for i in range(len(a)):
	if a[i] == 0 and b[i] == 1:
		zeros += 1
for i in range(len(a)):
	if a[i] == 0 and b[i] == 0:
		ways += ones
	if a[i] == 1 and b[i] == 0:
		ways += zeros
print(ways)


n = int(input())
a = input()
b = input()
aa = '0011'
bb = '0101'
counts = [0, 0, 0, 0]
for i in range(n):
	for j in range(len(aa)):
		if a[i] == aa[j] and b[i] == bb[j]:
			counts[j] += 1
res = counts[0] * counts[2] + counts[0] * counts[3] + counts[1] * counts[2]
print(res)


n = int(input())
z = input()
x = input()
xx = 0
od = 0
no = 0
odd = 0
noo = 0
m = 0
for i in range(n):
	if z[i] == '0':
		no += 1
	if z[i] == '1':
		od += 1
for i in range(n):
	if x[i] == '0':
		if z[i] == '0':
			noo = noo + 1
			m = m + od
		if z[i] == '1':
			m = m + no
			odd = odd + 1
if noo > 0 and odd > 0:
	m = m - noo * odd
print(m)


length = int(input())
a = input()
b = input()
ab = []
for i in range(length):
	ab.append([int(a[i]), int(b[i])])
total_00 = 0
total_10 = 0
total_01 = 0
total_11 = 0
for i in ab:
	if i == [0, 0]:
		total_00 += 1
	elif i == [1, 0]:
		total_10 += 1
	elif i == [0, 1]:
		total_01 += 1
	elif i == [1, 1]:
		total_11 += 1
res = 0
for i in ab:
	if i == [0, 0]:
		total_00 -= 1
		res += total_10
		res += total_11
	elif i == [1, 0]:
		total_10 -= 1
		res += total_00
		res += total_01
	elif i == [0, 1]:
		total_01 -= 1
		res += total_10
	elif i == [1, 1]:
		total_11 -= 1
		res += total_00
print(res)


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


n = int(input())
(a, b) = (input(), input())
(with_ones, with_zeros) = (0, 0)
for i in range(n):
	if a[i] == '0':
		if b[i] == '1':
			with_ones += 1
		else:
			with_zeros += 1
num_c = 0
for i in range(n):
	if a[i] == '1':
		if b[i] == '0':
			num_c += with_ones + with_zeros
		else:
			num_c += with_zeros
print(num_c)


(n, a, b) = (int(input()), input(), input())
(z, o) = (len(list(filter(lambda i: a[i] == '0' and b[i] == '0', range(n)))), len(list(filter(lambda i: a[i] == '1' and b[i] == '0', range(n)))))
print(z * a.count('1') + o * a.count('0') - z * o)


n = int(input())
a = input()
b = input()
total_one = [0] * (n + 1)
total_zero = [0] * (n + 1)
total_zero_blue = [0] * (n + 1)
total_one_blue = [0] * (n + 1)
for i in range(n):
	total_one[i + 1] = total_one[i] + (a[i] == '1')
	total_zero[i + 1] = total_zero[i] + (a[i] == '0')
	total_zero_blue[i + 1] = total_zero_blue[i] + ((a[i] == '0') & (b[i] == '1'))
	total_one_blue[i + 1] = total_one_blue[i] + ((a[i] == '1') & (b[i] == '1'))
res = 0
for i in range(n):
	if b[i] == '0':
		if a[i] == '1':
			res += total_zero[n] - total_zero[i + 1]
			res += total_zero_blue[i + 1]
		else:
			res += total_one[n] - total_one[i + 1]
			res += total_one_blue[i + 1]
print(res)


n = int(input())
a = input()
b = input()
cnt = 0
co = a.count('1')
cz = a.count('0')
for i in range(n):
	if a[i] == b[i] == '0':
		cnt += co
		cz -= 1
	elif a[i] == '1' and b[i] == '0':
		cnt += cz
		co -= 1
print(cnt)


n = int(input())
a = [str(j) for j in input()]
b = [str(j) for j in input()]
c = []
count = 0
for i in range(n):
	if a[i] == '1' or b[i] == '1':
		c.append('1')
	else:
		c.append('0')
zeroCounter = 0
oneCounter = 0
ones = a.count('1')
zeros = a.count('0')
for i in range(n):
	if b[i] == '0':
		if c[i] == '0':
			count += ones - oneCounter
			zeroCounter += 1
		else:
			count += zeros - zeroCounter
			oneCounter += 1
print(count)


import sys
from collections import defaultdict as dd
from collections import deque
from fractions import Fraction as f
from copy import *
from bisect import *
from heapq import *
from itertools import permutations

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')

def li():
	return [int(x) for x in input().split()]

def fi():
	return int(input())

def si():
	return list(input().rstrip())

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

def gh():
	sys.stdout.flush()

def graph(n, m):
	for i in range(m):
		(x, y) = mi()
		a[x].append(y)
		a[y].append(x)

def bo(i):
	return ord(i) - ord('a')
n = fi()
a = si()
b = si()
d = [0, 0]
l = [0, 0]
for i in range(n):
	if a[i] == '0':
		d[0] += 1
	else:
		d[1] += 1
	if b[i] == '0':
		l[int(a[i])] += 1
c = 0
for i in range(n):
	if b[i] == '0':
		if a[i] == '0':
			c += d[1]
		else:
			c += d[0]
print(c - l[0] * l[1])


n = int(input())
a = input()
b = input()
swap_zero = 0
swap_one = 0
num_zero = 0
num_one = 0
for i in range(n):
	if a[i] == '0' and b[i] == '0':
		swap_zero += 1
	if a[i] == '1' and b[i] == '0':
		swap_one += 1
	if a[i] == '0':
		num_zero += 1
	else:
		num_one += 1
ans = swap_zero * num_one + swap_one * num_zero - swap_one * swap_zero
print(ans)