Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options:

  on this day the gym is closed and the contest is not carried out;  on this day the gym is closed and the contest is carried out;  on this day the gym is open and the contest is not carried out;  on this day the gym is open and the contest is carried out. 

On each of days Vasya can either have a rest or write the contest (if it is carried out on this day), or do sport (if the gym is open on this day).

Find the minimum number of days on which Vasya will have a rest (it means, he will not do sport and write the contest at the same time). The only limitation that Vasya has — he does not want to do the same activity on two consecutive days: it means, he will not do sport on two consecutive days, and write the contest on two consecutive days.


-----Input-----

The first line contains a positive integer n (1 ≤ n ≤ 100) — the number of days of Vasya's vacations.

The second line contains the sequence of integers a_1, a_2, ..., a_{n} (0 ≤ a_{i} ≤ 3) separated by space, where: 

  a_{i} equals 0, if on the i-th day of vacations the gym is closed and the contest is not carried out;  a_{i} equals 1, if on the i-th day of vacations the gym is closed, but the contest is carried out;  a_{i} equals 2, if on the i-th day of vacations the gym is open and the contest is not carried out;  a_{i} equals 3, if on the i-th day of vacations the gym is open and the contest is carried out.


-----Output-----

Print the minimum possible number of days on which Vasya will have a rest. Remember that Vasya refuses:

  to do sport on any two consecutive days,  to write the contest on any two consecutive days. 


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

1 3 2 0


Output
2


Input
7

1 3 3 2 1 2 3


Output
0


Input
2

2 2


Output
1




-----Note-----

In the first test Vasya can write the contest on the day number 1 and do sport on the day number 3. Thus, he will have a rest for only 2 days.

In the second test Vasya should write contests on days number 1, 3, 5 and 7, in other days do sport. Thus, he will not have a rest for a single day.

In the third test Vasya can do sport either on a day number 1 or number 2. He can not do sport in two days, because it will be contrary to the his limitation. Thus, he will have a rest for only one day.

Difficulty: MEDIUM

Solutions:
def vacations(n, a):
	s = None
	r = 0
	for i in range(n):
		if a[i] == 0:
			r += 1
			s = 0
		elif a[i] == 1:
			if s == 1:
				r += 1
				s = 0
				continue
			else:
				s = 1
		elif a[i] == 2:
			if s == 2:
				r += 1
				s = 0
				continue
			else:
				s = 2
		elif s == 1:
			s = 2
		elif s == 2:
			s = 1
		elif i != n - 1 and a[i + 1] == 1:
			s = 2
		elif i != n - 1 and a[i + 1] == 2:
			s = 1
	print(r)
	return
n = int(input())
a = list(map(int, input().split(' ')))
vacations(n, a)


import math
import sys
input = sys.stdin.readline

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

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

def insr():
	s = input().strip()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())
n = inp()
l = inlt()
dp = [[0 for i in range(2)] for j in range(n)]
for i in range(n):
	if l[i] == 1:
		if max(dp[i - 1][0], dp[i - 1][1]) == dp[i - 1][1]:
			dp[i][0] = dp[i - 1][1] + 1
	elif l[i] == 2:
		if max(dp[i - 1][0], dp[i - 1][1]) == dp[i - 1][0]:
			dp[i][1] = dp[i - 1][0] + 1
	elif l[i] == 3:
		(dp[i][0], dp[i][1]) = (dp[i - 1][1] + 1, dp[i - 1][0] + 1)
mx = 1
cnt = 0
for i in range(n):
	if max(dp[i][0], dp[i][1]) == 0:
		cnt += 1
print(cnt)


n = int(input())
arr = list(map(int, input().rstrip().split()))
rest = 0
past = 0
i = 0
for i in range(len(arr)):
	if arr[i] == 0 or arr[i] == past:
		rest += 1
		past = 0
	elif arr[i] == 3:
		if past != 0:
			past = 3 - past
	else:
		past = arr[i]
print(rest)


import sys
input = sys.stdin.readline

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

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

def helper(i, choice):
	if i == n:
		return 0
	if (i, choice) in hash_map:
		return hash_map[i, choice]
	if arr[i] == 0:
		c_0 = 1 + helper(i + 1, 0)
		hash_map[i, choice] = c_0
		return c_0
	elif arr[i] == 1:
		c_1 = 0
		if choice == 1:
			c_1 = 1 + helper(i + 1, 0)
		elif choice == 0:
			c_1 = helper(i + 1, 1)
		elif choice == 2:
			c_1 = min(helper(i + 1, 1), 1 + helper(i + 1, 0))
		hash_map[i, choice] = c_1
		return c_1
	elif arr[i] == 2:
		c_2 = 0
		if choice == 2:
			c_2 = 1 + helper(i + 1, 0)
		elif choice == 0:
			c_2 = helper(i + 1, 2)
		elif choice == 1:
			c_2 = min(helper(i + 1, 2), 1 + helper(i + 1, 0))
		hash_map[i, choice] = c_2
		return c_2
	else:
		c_3 = 0
		if choice == 0:
			c_3 = min(helper(i + 1, 1), helper(i + 1, 2))
		if choice == 1:
			c_3 = min(helper(i + 1, 2), 1 + helper(i + 1, 0))
		if choice == 2:
			c_3 = min(helper(i + 1, 1), 1 + helper(i + 1, 0))
		hash_map[i, choice] = c_3
		return c_3

def solve(n, arr):
	return helper(0, 0)
n = inp()
arr = inlt()
hash_map = {}
print(solve(n, arr))


import sys
input = sys.stdin.readline
n = int(input())
l = list(map(int, input().split()))
dp = [[float('inf') for i in range(3)] for i in range(n)]
dp[0][2] = 1
if l[0] == 3:
	dp[0][0] = 0
	dp[0][1] = 0
elif l[0] == 2:
	dp[0][0] = 0
elif l[0] == 1:
	dp[0][1] = 0
for i in range(1, n):
	cur = l[i]
	dp[i][2] = min(dp[i - 1][0], dp[i - 1][1], dp[i - 1][2]) + 1
	if cur == 1:
		dp[i][1] = min(dp[i - 1][0], dp[i - 1][2])
	elif cur == 2:
		dp[i][0] = min(dp[i - 1][1], dp[i - 1][2])
	elif cur == 3:
		dp[i][0] = min(dp[i - 1][1], dp[i - 1][2])
		dp[i][1] = min(dp[i - 1][0], dp[i - 1][2])
print(min(dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]))


x = int(input())
m = list(map(int, input().split()))
a = [[-1791791791] * 4 for i in range(x)]
a[0][0] = 0
if m[0] & 1:
	a[0][1] = 1
if m[0] & 2:
	a[0][2] = 1
for i in range(1, x):
	a[i][0] = max(a[i - 1])
	for j in range(1, 3):
		if m[i] & j:
			a[i][j] = max(a[i - 1][:j] + a[i - 1][j + 1:]) + 1
maxx = max(a[-1])
print(x - maxx)


_ = input()
days = map(int, input().split())
off = 0
last = 0
for d in days:
	if d == 0:
		off += 1
		last = 0
	elif last == 0 or last == 3:
		last = d
	elif d in {3, 3 - last}:
		last = 3 - last
	else:
		off += 1
		last = 0
print(off)


n = int(input())
a = list(map(int, input().split()))
arr = [[0, 0, 0]]
for i in range(n):
	f = a[i]
	r = max(arr[i][0], arr[i][1], arr[i][2])
	c = arr[i][1]
	g = arr[i][2]
	if f == 1 or f == 3:
		c = max(arr[i][0], arr[i][2]) + 1
	if f == 2 or f == 3:
		g = max(arr[i][0], arr[i][1]) + 1
	arr.append([r, c, g])
print(n - max(arr[-1][0], arr[-1][1], arr[-1][2]))


from sys import stdin, stdout
from array import array

def solve(days):
	rest_num = 0
	prev_act = 0
	for i in range(0, len(days) - 1):
		cur_act = days[i]
		next_act = days[i + 1]
		if cur_act == 0 or prev_act == cur_act:
			prev_act = 0
			rest_num += 1
		elif prev_act != cur_act and cur_act != 3:
			prev_act = cur_act
		elif prev_act in (1, 2):
			prev_act = prev_act % 2 + 1
		elif next_act in (1, 2):
			prev_act = next_act % 2 + 1
	return rest_num

def __starting_point():
	use_stdio = True
	days = []
	if use_stdio:
		length = int(stdin.readline())
		days = array('i', list(map(int, stdin.readline().split())) + [3])
		stdout.write(str(solve(days)))
	else:
		with open('input', 'r') as fin, open('output', 'w') as fout:
			length = int(fin.readline())
			days = array('i', list(map(int, fin.readline().split())) + [3])
			fout.write(str(solve(days)))
__starting_point()


n = int(input())
dp = [[0 for i in range(3)] for j in range(n + 1)]
a = list(map(int, input().split()))
for i in range(1, n + 1):
	if a[i - 1] == 1 or a[i - 1] == 3:
		dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + 1
	if a[i - 1] == 2 or a[i - 1] == 3:
		dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + 1
	dp[i][0] = max(max(dp[i - 1][0], dp[i - 1][1]), dp[i - 1][2])
print(n - max(max(dp[n][0], dp[n][1]), dp[n][2]))


n = int(input())
a = list(map(int, input().split()))
dp = [[0] * n for i in range(2)]
if a[0] == 0:
	dp[0][0] = 1
	dp[1][0] = 1
elif a[0] == 1:
	dp[0][0] = 1
elif a[0] == 2:
	dp[1][0] = 1
for i in range(1, n):
	if a[i] == 0:
		dp[0][i] = 1 + min(dp[0][i - 1], dp[1][i - 1])
		dp[1][i] = 1 + min(dp[0][i - 1], dp[1][i - 1])
	elif a[i] == 1:
		dp[0][i] = 1 + min(dp[0][i - 1], dp[1][i - 1])
		dp[1][i] = dp[0][i - 1]
	elif a[i] == 2:
		dp[0][i] = dp[1][i - 1]
		dp[1][i] = 1 + min(dp[0][i - 1], dp[1][i - 1])
	else:
		dp[0][i] = dp[1][i - 1]
		dp[1][i] = dp[0][i - 1]
print(min(dp[0][-1], dp[1][-1]))


def sport(v):
	return v >= 2

def contest(v):
	return v in [1, 3]
LAST_CONTEST = 0
LAST_SPORT = 1

def __starting_point():
	n = int(input())
	a = list(map(int, input().split()))
	prev = [0, 0]
	dp = [0, 0]
	for i in range(n):
		v = a[i]
		curr = [dp[0], dp[1]]
		if sport(v):
			curr[LAST_SPORT] = max(dp[LAST_SPORT], 1 + prev[LAST_SPORT], 1 + dp[LAST_CONTEST])
		if contest(v):
			curr[LAST_CONTEST] = max(dp[LAST_CONTEST], 1 + prev[LAST_CONTEST], 1 + dp[LAST_SPORT])
		prev = dp
		dp = curr
	print(n - max(dp))
__starting_point()


input()
B = 10000
s = [0, B, B]
for x in map(int, input().split()):
	s = [min(s) + 1, min(s[0::2]) if x & 1 else B, min(s[:2]) if x & 2 else B]
print(min(s))


n = int(input())
a = list(map(int, input().split()))
prev = 0
ans = 0
for i in range(n):
	k = a[i]
	if k == 0:
		prev = 0
		ans += 1
	elif k == 1 or k == 2:
		if prev == k:
			ans += 1
			prev = 0
		else:
			prev = k
	elif prev == 1 or prev == 2:
		prev = 3 - prev
	else:
		prev = 4
print(ans)


def main():
	input()
	a1 = a2 = x1 = x2 = z = 0
	for b in map(int, input()[::2]):
		if 0 < b < 3:
			if a1 == b:
				a1 = 0
				x1 += 1
			else:
				a1 = b
			if a2 == b:
				a2 = 0
				x2 += 1
			else:
				a2 = b
			if x1 != x2:
				if x1 > x2:
					(x1, a1) = (x2, a2)
				else:
					(x2, a2) = (x1, a1)
		elif b:
			a1 = 1 if a1 != 1 else 2
			a2 = 2 if a2 != 2 else 1
		else:
			a1 = a2 = 0
			z += 1
	print(x1 + z)

def __starting_point():
	main()
__starting_point()


R = lambda : map(int, input().split())
n = int(input())
dp = [[0, 0, 0] for i in range(n + 1)]
for (i, x) in enumerate(R()):
	dp[i][0] = min(dp[i - 1]) + 1
	if x == 3:
		dp[i][1] = min(dp[i - 1][0], dp[i - 1][2])
		dp[i][2] = min(dp[i - 1][0], dp[i - 1][1])
	elif x == 2:
		dp[i][1] = n + 1
		dp[i][2] = min(dp[i - 1][0], dp[i - 1][1])
	elif x == 1:
		dp[i][1] = min(dp[i - 1][0], dp[i - 1][2])
		dp[i][2] = n + 1
	else:
		dp[i] = [min(dp[i - 1]) + 1] * 3
print(min(dp[n - 1]))


t = int(input())
s = list(map(int, input().split()))
dp1 = [0 for i in range(t)]
dp2 = [0 for i in range(t)]
dp1[0] = 0 if s[0] & 1 else 1
dp2[0] = 0 if s[0] & 2 else 1
for i in range(1, t):
	if s[i] == 3:
		(dp1[i], dp2[i]) = (dp2[i - 1], dp1[i - 1])
	elif s[i] == 2:
		(dp1[i], dp2[i]) = (min(dp1[i - 1], dp2[i - 1]) + 1, dp1[i - 1])
	elif s[i] == 1:
		(dp1[i], dp2[i]) = (dp2[i - 1], min(dp1[i - 1], dp2[i - 1]) + 1)
	else:
		dp2[i] = dp1[i] = min(dp1[i - 1], dp2[i - 1]) + 1
print(min(dp1[t - 1], dp2[t - 1]))


n = int(input())
data = list(map(int, input().split()))
ans = 0
prev = 0
i = 0
while i < n:
	if data[i] is 0:
		ans = ans + 1
		prev = 0
	elif data[i] is 1:
		if prev is 1:
			ans += 1
			prev = 0
		else:
			prev = 1
	elif data[i] is 2:
		if prev is 2:
			ans += 1
			prev = 0
		else:
			prev = 2
	elif prev is 1:
		prev = 2
	elif prev is 2:
		prev = 1
	else:
		j = i
		while j < n:
			if data[j] is not 3:
				i = j - 1
				break
			j += 1
	i += 1
print(ans)


INF = 1000
n = int(input())
desc = list(map(int, input().split()))
r = {}
g = {}
c = {}
r[0] = 0
g[0] = 0
c[0] = 0
i = 0
for x in desc:
	i += 1
	if x == 0:
		g[i] = INF
		c[i] = INF
		r[i] = 1 + min([g[i - 1], r[i - 1], c[i - 1]])
	elif x == 1:
		g[i] = INF
		c[i] = min(r[i - 1], g[i - 1])
		r[i] = 1 + min([g[i - 1], r[i - 1], c[i - 1]])
	elif x == 2:
		g[i] = min(r[i - 1], c[i - 1])
		c[i] = INF
		r[i] = 1 + min([g[i - 1], r[i - 1], c[i - 1]])
	elif x == 3:
		r[i] = 1 + min([g[i - 1], r[i - 1], c[i - 1]])
		g[i] = min(r[i - 1], c[i - 1])
		c[i] = min(r[i - 1], g[i - 1])
print(min([r[n], g[n], c[n]]))


n = int(input())
l = list(map(int, input().split()))
gym = -1
contest = -1
rest = 0
if l[0] == 0:
	rest += 1
elif l[0] == 1:
	contest = 0
elif l[0] == 2:
	gym = 0
elif n > 1:
	if l[1] == 2:
		contest = 0
	elif l[1] == 1:
		gym = 0
	else:
		contest = 0
for i in range(1, n):
	if l[i] == 0:
		rest += 1
	elif l[i] == 1:
		if contest == i - 1:
			rest += 1
		else:
			contest = i
	elif l[i] == 2:
		if gym == i - 1:
			rest += 1
		else:
			gym = i
	elif contest == i - 1:
		gym = i
	elif gym == i - 1:
		contest = i
rest1 = 0
if l[0] == 0:
	rest1 += 1
elif l[0] == 1:
	contest = 0
elif l[0] == 2:
	gym = 0
elif n > 1:
	if l[1] == 2:
		contest = 0
	elif l[1] == 1:
		gym = 0
	else:
		gym = 0
for i in range(1, n):
	if l[i] == 0:
		rest1 += 1
	elif l[i] == 1:
		if contest == i - 1:
			rest1 += 1
		else:
			contest = i
	elif l[i] == 2:
		if gym == i - 1:
			rest1 += 1
		else:
			gym = i
	elif contest == i - 1:
		gym = i
	elif gym == i - 1:
		contest = i
print(min(rest, rest1))


input()
l = list(map(int, input().split()))
r = 0
prev = 3
for i in l:
	if i == prev and prev != 3:
		i = 0
	elif i == 3 and prev != 3:
		i -= prev
	if i == 0:
		r = r + 1
	prev = i
print(r)


n = int(input())
a = list(map(int, input().split()))

def func(b, p):
	if len(b) == 1:
		if p == 0:
			if b[0] == 0:
				return 1
			else:
				return 0
		elif p == 1:
			if b[0] == 0 or b[0] == 1:
				return 1
			else:
				return 0
		elif p == 2:
			if b[0] == 0 or b[0] == 2:
				return 1
			else:
				return 0
		elif b[0] == 0:
			return 1
		else:
			return 0
	else:
		c = b[1:]
		if p == 0:
			if b[0] == 0:
				return 1 + func(c, 0)
			else:
				return func(c, b[0])
		elif p == 1:
			if b[0] == 0 or b[0] == 1:
				return 1 + func(c, 0)
			else:
				return func(c, 2)
		elif p == 2:
			if b[0] == 0 or b[0] == 2:
				return 1 + func(c, 0)
			else:
				return func(c, 1)
		elif b[0] == 0:
			return 1 + func(c, 0)
		else:
			return func(c, b[0])
print(func(a, 0))


from sys import stdin
input = stdin.readline
n = int(input())
a = list(map(int, input().split()))
dp = [0] * n
dp[0] = a[0]
for i in range(1, n):
	if a[i] == 0:
		dp[i] = 0
	if a[i] == 1:
		if dp[i - 1] == 1:
			dp[i] = 0
		if dp[i - 1] != 1:
			dp[i] = 1
	if a[i] == 2:
		if dp[i - 1] == 2:
			dp[i] = 0
		if dp[i - 1] != 2:
			dp[i] = 2
	if a[i] == 3:
		if dp[i - 1] == 1:
			dp[i] = 2
		if dp[i - 1] == 2:
			dp[i] = 1
		if dp[i - 1] == 3 or dp[i - 1] == 0:
			dp[i] = 3
print(dp.count(0))


n = int(input())
m = [int(x) for x in input().split()]
l = []
if m[0] == 0:
	l.append([0, 0, 0])
elif m[0] == 1:
	l.append([0, 1, 0])
elif m[0] == 2:
	l.append([0, 0, 1])
else:
	l.append([0, 1, 1])
for i in range(1, n):
	if m[i] == 0:
		l.append([max(l[i - 1]), max(l[i - 1]), max(l[i - 1])])
	elif m[i] == 1:
		l.append([max(l[i - 1]), max(l[i - 1][0], l[i - 1][2]) + 1, max(l[i - 1][0], l[i - 1][1])])
	elif m[i] == 2:
		l.append([max(l[i - 1]), max(l[i - 1][0], l[i - 1][2]), max(l[i - 1][0], l[i - 1][1]) + 1])
	else:
		l.append([max(l[i - 1]), max(l[i - 1][0], l[i - 1][2]) + 1, max(l[i - 1][0], l[i - 1][1]) + 1])
print(n - max(l[n - 1]))


n = int(input())
line = [int(x) for x in input().split()]
d = [0] * 3
for i in line:
	d_1 = d[:]
	d[0] = min(d_1) + 1
	if i == 1:
		d[1] = min(d_1[0], d_1[2])
		d[2] = 10 ** 6
	elif i == 2:
		d[2] = min(d_1[0], d_1[1])
		d[1] = 10 ** 6
	elif i == 3:
		d[1] = min(d_1[0], d_1[2])
		d[2] = min(d_1[0], d_1[1])
	elif i == 0:
		d[1] = 10 ** 6
		d[2] = 10 ** 6
print(min(d))


n = int(input())
days = [int(_) for _ in input().split()]
ff = {(0, n): 0, (1, n): 0, (2, n): 0}

def f(t, k):
	if not (t, k) in ff:
		www = []
		for x in range(3):
			if x == 0:
				www.append(f(x, k + 1) + 1)
			elif x & days[k] and (t == 0 or t != x):
				www.append(f(x, k + 1))
		ff[t, k] = min(www)
	return ff[t, k]
print(f(0, 0))


def main():
	n = input()
	L = [int(x) for x in input().split()]
	print(solver(L))

def solver(L):
	return helper(L, None)

def helper(L, last):
	if len(L) == 0:
		return 0
	x = L[0]
	if last == 'gym':
		if L[0] in [0, 2]:
			return 1 + helper(L[1:], None)
		elif L[0] in [1, 3]:
			return helper(L[1:], 'contest')
	elif last == 'contest':
		if L[0] in [0, 1]:
			return 1 + helper(L[1:], None)
		elif L[0] in [2, 3]:
			return helper(L[1:], 'gym')
	elif last == None:
		if L[0] == 0:
			return 1 + helper(L[1:], None)
		elif L[0] == 1:
			return helper(L[1:], 'contest')
		elif L[0] == 2:
			return helper(L[1:], 'gym')
		elif L[0] == 3:
			for i in range(1, len(L)):
				if L[i] == 0:
					return 1 + helper(L[i + 1:], None)
				elif L[i] == 1:
					return helper(L[i + 1:], 'contest')
				elif L[i] == 2:
					return helper(L[i + 1:], 'gym')
			return 0
	else:
		assert False
main()


def dp(prev, ind):
	nonlocal dar, n, con, gym
	if ind >= n:
		return 0
	if (prev, ind) not in dar:
		m = dp('free', ind + 1) + 1
		if prev != 'con' and con[ind]:
			m = min(m, dp('con', ind + 1))
		if prev != 'gym' and gym[ind]:
			m = min(m, dp('gym', ind + 1))
		dar[prev, ind] = m
	return dar[prev, ind]
dar = {}
n = int(input())
L = [int(x) for x in input().split()]
con = [x & 1 for x in L]
gym = [x & 2 for x in L]
print(dp('free', 0))


a = int(input())
b = list(map(int, input().split()))
k = []
n = 0
z = b.count(0)
for i in range(a - 1):
	if b[i] in [1, 2]:
		if b[i] == b[i + 1]:
			n += 1
			b[i + 1] = 0
		elif b[i + 1] == 3:
			b[i + 1] = 3 - b[i]
print(n + z)


days = int(input())
events = [int(_) for _ in input().split()]
rests = 0
last = 0
for event in events:
	if event == 0:
		rests += 1
		last = 0
	elif event == 1:
		if last == 1:
			rests += 1
			last = 0
		else:
			last = 1
	elif event == 2:
		if last == 2:
			rests += 1
			last = 0
		else:
			last = 2
	elif last == 1:
		last = 2
	elif last == 2:
		last = 1
print(rests)


n = int(input())
s = [0] + list(map(int, input().split()))
r = [0 for i in range(n + 1)]
r[0] = 1
if s[1] == 0:
	r[1] = 2
else:
	r[1] = 1
for i in range(2, n + 1):
	if s[i] == 0:
		r[i] = r[i - 1] + 1
	if s[i] == 3:
		r[i] = r[i - 1]
	if s[i] == 2:
		if s[i - 1] == 2:
			r[i] = r[i - 2] + 1
		if s[i - 1] == 1 or s[i - 1] == 0:
			r[i] = r[i - 1]
		if s[i - 1] == 3:
			temp = i - 1
			c = 0
			while s[temp] == 3:
				c += 1
				temp -= 1
			num = s[temp]
			if num == 0:
				r[i] = r[temp]
			if num == 1:
				r[i] = r[temp - c % 2] + c % 2
			if num == 2:
				r[i] = r[temp - (c + 1) % 2] + (c + 1) % 2
	if s[i] == 1:
		if s[i - 1] == 1:
			r[i] = r[i - 2] + 1
		if s[i - 1] == 2 or s[i - 1] == 0:
			r[i] = r[i - 1]
		if s[i - 1] == 3:
			temp = i - 1
			c = 0
			while s[temp] == 3:
				c += 1
				temp -= 1
			num = s[temp]
			if num == 0:
				r[i] = r[temp]
			if num == 2:
				r[i] = r[temp - c % 2] + c % 2
			if num == 1:
				r[i] = r[temp - (c + 1) % 2] + (c + 1) % 2
print(max(r) - 1)


n = int(input())
last = -1
a = list(map(int, input().split()))
ans = 0
for x in a:
	if x == 0:
		last = -1
		ans += 1
	elif x < 3:
		if last == x:
			last = -1
			ans += 1
			continue
		last = x
	elif last == 1:
		last = 2
	elif last == 2:
		last = 1
	else:
		last = -1
print(ans)


n = int(input())
ls = list(map(int, input().split()))
from functools import lru_cache

@lru_cache(maxsize=None)
def f(i, last=''):
	if i == n:
		return 0
	c = 0
	for j in range(i, n):
		if ls[j] == 0:
			c += 1
			last = ''
		elif ls[j] == 1:
			if last == 'contest':
				c += 1
				last = ''
			else:
				last = 'contest'
		elif ls[j] == 2:
			if last == 'gym':
				c += 1
				last = ''
			else:
				last = 'gym'
		elif last == 'contest':
			last = 'gym'
		elif last == 'gym':
			last = 'contest'
		else:
			return min(c + f(j + 1, 'contest'), c + f(j + 1, 'gym'))
	return c
print(f(0))


user = int(input())
n = list(input().split(' '))
l = len(n) - 1
if int(n[0]) == 3 and int(n[l]) != 3:
	n.reverse()
r = 0
a = 0
c = 0
res = []
for i in n:
	if int(i) == 0:
		r = r + 1
		a = 0
		c = c + 1
	if int(i) == 1:
		if a == 0 or a != 2:
			a = 2
			c = c + 1
		else:
			r = r + 1
			a = 0
			c = c + 1
	if int(i) == 2:
		if a == 0 or a != 1:
			a = 1
			c = c + 1
		else:
			r = r + 1
			a = 0
			c = c + 1
	if int(i) == 3:
		if a == 0:
			while c < len(n) and n[c] == 3:
				c = c + 1
			if c < len(n):
				if n[c] == 1:
					a = 2
				elif n[c] == 2:
					a = 1
		elif a != 1:
			a = 1
		elif a != 2:
			a = 2
print(r)


import os, 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))
try:
	(sys.stdin, sys.stdout) = (open('in.txt', 'r'), open('out.txt', 'w'))
except:
	pass
ii1 = lambda : int(sys.stdin.readline().strip())
is1 = lambda : sys.stdin.readline().strip()
iia = lambda : list(map(int, sys.stdin.readline().strip().split()))
isa = lambda : sys.stdin.readline().strip().split()
mod = int(1000000000.0 + 7)
from collections import *
from math import *
from functools import lru_cache
from collections import deque as dq

class sol:

	def __init__(self):
		self.n = ii1()
		self.arr = iia()
		self.solve()

	def solve(self):

		@lru_cache(None)
		def fun(idx, state):
			if idx == self.n:
				return 0
			if state == 0:
				curr = self.arr[idx]
				if curr == 0:
					return fun(idx + 1, curr)
				elif curr == 1:
					return max(1 + fun(idx + 1, curr), fun(idx + 1, 0))
				elif curr == 2:
					return max(1 + fun(idx + 1, curr), fun(idx + 1, 0))
				elif curr == 3:
					return max(fun(idx + 1, 1) + 1, fun(idx + 1, 2) + 1, fun(idx + 1, 0))
			elif state == 1:
				curr = self.arr[idx]
				if curr == 0:
					return fun(idx + 1, curr)
				elif curr == 1:
					return fun(idx + 1, 0)
				elif curr == 2:
					return max(1 + fun(idx + 1, curr), fun(idx + 1, 0))
				elif curr == 3:
					return max(1 + fun(idx + 1, 2), fun(idx + 1, 0))
			elif state == 2:
				curr = self.arr[idx]
				if curr == 0:
					return fun(idx + 1, curr)
				elif curr == 1:
					return max(1 + fun(idx + 1, curr), fun(idx + 1, 0))
				elif curr == 2:
					return fun(idx + 1, 0)
				elif curr == 3:
					return max(1 + fun(idx + 1, 1), fun(idx + 1, 0))
			else:
				curr = self.arr[idx]
				if curr == 0:
					return fun(idx + 1, curr)
				elif curr == 1:
					return max(1 + fun(idx + 1, curr), fun(idx + 1, 0))
				elif curr == 2:
					return max(1 + fun(idx + 1, curr), fun(idx + 1, 0))
				else:
					return max(1 + fun(idx + 1, 1), 1 + fun(idx + 1, 2), fun(idx + 1, 0))
		ans = fun(0, -1)
		print(self.n - ans)
sol()


n = int(input())
a = list(map(int, input().split()))
cur = ans = 0
for i in a:
	if i == 0:
		cur = 0
		ans += 1
	if i == 1:
		if cur in (0, 1):
			cur = 2
		else:
			cur = 0
			ans += 1
	if i == 2:
		if cur in (0, 2):
			cur = 1
		else:
			cur = 0
			ans += 1
	if i == 3:
		cur = {0: 0, 1: 2, 2: 1}[cur]
print(ans)


def get_ints(string):
	return list(map(int, string.split()))

def get_input():
	n = int(input())
	xs = get_ints(input())
	return (n, xs)

def foo(xs, res, last):
	if len(xs) is []:
		return res
	for (i, x) in enumerate(xs):
		if x == 0:
			res += 1
			last = 0
		elif x == 1 and last == 1:
			res += 1
			last = 0
		elif x == 1:
			last = 1
		elif x == 2 and last == 2:
			res += 1
			last = 0
		elif x == 2:
			last = 2
		elif last == 1:
			last = 2
		elif last == 2:
			last = 1
		elif i < len(xs) - 1 and xs[i + 1] == 0:
			last = 1
		else:
			return min(foo(xs[i + 1:], res, 1), foo(xs[i + 1:], res, 2))
	return res

def main():
	(n, xs) = get_input()
	res = foo(xs, 0, 0)
	print(res)
	return res

def __starting_point():
	main()
__starting_point()


n_days = int(input())
days = list(map(int, input().split()))
dp = [[-1, -1, -1] for i in range(n_days)]
dp.append([0, 0, 0])
for i in range(n_days - 1, -1, -1):
	dp[i][0] = int(max(dp[i + 1]))
	if days[i] == 1 or days[i] == 3:
		dp[i][1] = int(max(max(dp[i + 1][0] + 1, dp[i + 1][2] + 1), dp[i + 1][1]))
	if days[i] == 2 or days[i] == 3:
		dp[i][2] = int(max(max(dp[i + 1][0] + 1, dp[i + 1][1] + 1), dp[i + 1][2]))
print(n_days - max(dp[0]))


3
n = int(input())
a = list(map(int, input().split()))
dp = [[-1791791791] * 4 for i in range(n)]
dp[0][0] = 0
if a[0] & 1:
	dp[0][1] = 1
if a[0] & 2:
	dp[0][2] = 1
for i in range(1, n):
	dp[i][0] = max(dp[i - 1])
	for j in range(1, 3):
		if a[i] & j:
			dp[i][j] = max(dp[i - 1][:j] + dp[i - 1][j + 1:]) + 1
ans = max(dp[-1])
print(n - ans)


inf = 10000000000.0
mem = [[-1] * 5 for _ in range(110)]

def solve(i, u):
	if mem[i][u] != -1:
		return mem[i][u]
	if i == n:
		return 0
	g = h = inf
	if a[i] == 0:
		g = 1 + solve(i + 1, 0)
	elif a[i] == 1:
		if u == 1:
			g = 1 + solve(i + 1, 0)
		else:
			g = solve(i + 1, 1)
	elif a[i] == 2:
		if u == 2:
			g = 1 + solve(i + 1, 0)
		else:
			g = solve(i + 1, 2)
	elif u == 1:
		g = solve(i + 1, 2)
	elif u == 2:
		g = solve(i + 1, 1)
	else:
		g = solve(i + 1, 1)
		h = solve(i + 1, 2)
	mem[i][u] = min(g, h)
	return mem[i][u]
n = int(input())
a = list(map(int, input().split()))
print(solve(0, 0))


n = int(input())
d = list(map(int, input().split()))[:n]
dp = [[int(101) for i in range(100)] for j in range(3)]
dp[0][0] = 1
if d[0] == 1 or d[0] == 3:
	dp[1][0] = 0
if d[0] == 2 or d[0] == 3:
	dp[2][0] = 0
for i in range(1, n):
	dp[0][i] = 1 + min(dp[0][i - 1], dp[1][i - 1], dp[2][i - 1])
	if d[i] == 1 or d[i] == 3:
		dp[1][i] = min(dp[0][i - 1], dp[2][i - 1])
	if d[i] == 2 or d[i] == 3:
		dp[2][i] = min(dp[0][i - 1], dp[1][i - 1])
print(min(dp[0][n - 1], dp[1][n - 1], dp[2][n - 1]))


from sys import stdin
n = int(stdin.readline().rstrip())
l = list(map(int, stdin.readline().rstrip().split(' ')))
r = x = 0
for i in range(n):
	if l[i] == 0 or l[i] == x:
		r += 1
		x = 0
	elif l[i] == 3:
		if x:
			x = 3 - x
	else:
		x = l[i]
print(r)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
mod = pow(10, 9) + 7
mod2 = 998244353

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

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

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

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

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

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

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

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

@lru_cache(None)
def dp(A, l):
	if len(A) == 1:
		if l == 0:
			if A[0] != 0:
				return 1
			return 0
		if l == 1:
			if A[0] in [0, 1]:
				return 0
			else:
				return 1
		if l == 2:
			if A[0] in [0, 2]:
				return 0
			else:
				return 1
	if A[0] == 0:
		return dp(A[1:], 0)
	if A[0] == 1:
		if l != 1:
			return max(1 + dp(A[1:], 1), dp(A[1:], 0))
		else:
			return dp(A[1:], 0)
	if A[0] == 2:
		if l != 2:
			return max(1 + dp(A[1:], 2), dp(A[1:], 0))
		else:
			return dp(A[1:], 0)
	if A[0] == 3:
		if l == 0:
			return max(1 + dp(A[1:], 2), dp(A[1:], 0), 1 + dp(A[1:], 1))
		elif l == 1:
			return max(1 + dp(A[1:], 2), dp(A[1:], 0))
		else:
			return max(1 + dp(A[1:], 1), dp(A[1:], 0))
n = int(input())
A = tuple(map(int, input().split()))
x = dp(A, 0)
ans = n - x
print(ans)


n = int(input())
L = list(map(int, input().split()))

def pasa(x, y):
	return x == 1 and y == 2 or (x == 2 and y == 1)
if n == 1:
	print(L.count(0))
else:
	cont = 0
	for k in range(1, n):
		if L[k] != 0:
			if not pasa(L[k], L[k - 1]):
				if L[k] == 3 and (not L[k - 1] == 3):
					L[k] -= L[k - 1]
				elif L[k] == L[k - 1] and L[k] != 3:
					L[k] = 0
	print(L.count(0))


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

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

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

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
n = int(z())
l = zzz()
cur = ans = 0
for i in l:
	if i == 0:
		cur = 0
		ans += 1
	if i == 1:
		if cur in (0, 1):
			cur = 2
		else:
			cur = 0
			ans += 1
	if i == 2:
		if cur in (0, 2):
			cur = 1
		else:
			ans += 1
			cur = 0
	if i == 3:
		cur = {0: 0, 1: 2, 2: 1}[cur]
print(ans)


n = int(input())
num = [int(i) for i in input().split()]
dp = [[0 for i in range(3)] for j in range(102)]
for i in range(1, n + 1):
	if num[i - 1] == 0:
		dp[i][0] = min(dp[i - 1]) + 1
		dp[i][1] = float('inf')
		dp[i][2] = float('inf')
	if num[i - 1] == 1:
		dp[i][2] = float('inf')
		dp[i][0] = min(dp[i - 1][0], dp[i - 1][1], dp[i - 1][2]) + 1
		dp[i][1] = min(dp[i - 1][2], dp[i - 1][0])
	if num[i - 1] == 2:
		dp[i][1] = float('inf')
		dp[i][0] = min(dp[i - 1][0], dp[i - 1][1], dp[i - 1][2]) + 1
		dp[i][2] = min(dp[i - 1][1], dp[i - 1][0])
	if num[i - 1] == 3:
		dp[i][1] = min(dp[i - 1][0], dp[i - 1][2])
		dp[i][0] = min(dp[i - 1][0], dp[i - 1][1], dp[i - 1][2]) + 1
		dp[i][2] = min(dp[i - 1][1], dp[i - 1][0])
print(min(dp[n][0], dp[n][1], dp[n][2]))


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()
l = mp()
prev = 0
ans = 0
for i in range(n):
	if l[i] == 0 or l[i] == prev:
		ans += 1
		prev = 0
	elif l[i] == 2:
		prev = 2
	elif l[i] == 1:
		prev = 1
	elif prev > 0:
		prev = 3 - prev
print(ans)


input()
(p, c) = (3, 0)
for i in list(map(int, input().split())):
	if i == p and p != 3:
		i = 0
	elif i == 3 and p != 3:
		i -= p
	if i == 0:
		c += 1
	p = i
print(c)


n = int(input())
a = [0] + list(map(int, input().split()))
vix = 0
for i in range(1, n + 1):
	if a[i] == 0:
		vix += 1
	elif a[i] == 3:
		a[i] = 3 - a[i - 1]
	elif a[i] == a[i - 1]:
		vix += 1
		a[i] = 0
print(vix)


n = int(input())
days = input().split()
last = '0'
counter = 0
for i in range(n):
	if last == days[i] or days[i] == '0':
		counter += 1
		last = '0'
	elif days[i] != '3':
		last = days[i]
	elif last == '1':
		last = '2'
	elif last == '2':
		last = '1'
	elif i < n - 1:
		if days[i + 1] == '1':
			last = '2'
		elif days[i + 1] == '2':
			last = '1'
print(counter)


n = int(input())
a = list(map(int, input().split()))
d = [[10 ** 6] * 3 for i in range(n)]
d[0][0] = 1
if a[0] & 1:
	d[0][1] = 0
if a[0] & 2:
	d[0][2] = 0
for i in range(1, n):
	d[i][0] = min(d[i - 1]) + 1
	if a[i] & 1:
		d[i][1] = min(d[i - 1][0], d[i - 1][2])
	if a[i] & 2:
		d[i][2] = min(d[i - 1][0], d[i - 1][1])
print(min(d[-1]))


import sys
input = lambda : sys.stdin.readline()
int_arr = lambda : list(map(int, input().split()))
str_arr = lambda : list(map(str, input().split()))
get_str = lambda : map(str, input().split())
get_int = lambda : map(int, input().split())
get_flo = lambda : map(float, input().split())
mod = 1000000007

def solve(n, arr):
	prev = 0
	c = 0
	for i in range(n):
		if arr[i] == prev:
			c += 1
			prev = 0
		elif arr[i] == 0:
			c += 1
			prev = 0
		elif arr[i] == 1 or arr[i] == 2:
			prev = arr[i]
		elif prev:
			prev = 3 - prev
	print(c)
n = int(input())
arr = int_arr()
solve(n, arr)


from sys import stdin, stdout
from math import sqrt, floor, ceil
from collections import defaultdict
from collections import deque

def solve():
	pass

def main():
	for _ in range(1):
		n = int(input())
		A = [int(a) for a in input().split()]
		dp = [[0 for _ in range(4)] for _ in range(n)]
		MAXN = 1000
		if A[0] == 0:
			dp[0][0] = 1
			dp[0][1] = MAXN
			dp[0][2] = MAXN
		elif A[0] == 1:
			dp[0][0] = 1
			dp[0][1] = 0
			dp[0][2] = MAXN
		elif A[0] == 2:
			dp[0][0] = 1
			dp[0][1] = MAXN
			dp[0][2] = 0
		else:
			dp[0][0] = 1
			dp[0][1] = 0
			dp[0][2] = 0
		for i in range(1, n):
			if A[i] == 0:
				dp[i][0] = 1 + min([dp[i - 1][0], dp[i - 1][1], dp[i - 1][2]])
				dp[i][1] = MAXN
				dp[i][2] = MAXN
			elif A[i] == 1:
				dp[i][0] = 1 + min([dp[i - 1][0], dp[i - 1][1], dp[i - 1][2]])
				dp[i][1] = min([dp[i - 1][0], dp[i - 1][2]])
				dp[i][2] = MAXN
			elif A[i] == 2:
				dp[i][0] = 1 + min([dp[i - 1][0], dp[i - 1][1], dp[i - 1][2]])
				dp[i][1] = MAXN
				dp[i][2] = min([dp[i - 1][0], dp[i - 1][1]])
			else:
				dp[i][0] = 1 + min([dp[i - 1][0], dp[i - 1][1], dp[i - 1][2]])
				dp[i][1] = min([dp[i - 1][0], dp[i - 1][2]])
				dp[i][2] = min([dp[i - 1][0], dp[i - 1][1]])
		print(min([dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]]))
main()


num = int(input())
days = list(map(int, input().split()))
rest = 0
flag = 0
for j in range(len(days)):
	if days[j] == 0:
		flag = 0
		rest += 1
	elif days[j] == 1:
		if flag is not 1:
			flag = 1
		else:
			rest += 1
			flag = 0
	elif days[j] == 2:
		if flag is not 2:
			flag = 2
		else:
			rest += 1
			flag = 0
	else:
		if flag is 0:
			continue
		if flag is 1:
			flag = 2
		else:
			flag = 1
print(rest)


from sys import stdin
from math import inf
n = int(stdin.readline())
dp = [list([inf for i in range(4)]) for j in range(n + 1)]
dp[0][0] = dp[0][1] = dp[0][2] = dp[0][3] = 0
a = [0] + list(map(int, stdin.readline().split()))
for i in range(1, n + 1):
	dp[i][0] = min(dp[i - 1]) + 1
	if a[i] in (1, 3):
		dp[i][1] = min(dp[i - 1][0], dp[i - 1][2])
	if a[i] in (2, 3):
		dp[i][2] = min(dp[i - 1][0], dp[i - 1][1])
	if a[i] == 3:
		dp[i][3] = dp[i - 1][0]
print(min(dp[n]))


from math import *
import threading
import sys
from collections import defaultdict
sys.setrecursionlimit(300000)
mod = 10 ** 9
inf = 10 ** 15
yes = 'YES'
no = 'NO'
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 npr(n, r):
	return factorial(n) // factorial(n - r) if n >= r else 0

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(n - r)) if n >= r else 0

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):
	ans = -1
	lb = 0
	ub = len(li) - 1
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = mid
			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 = max(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

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	li = []
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, len(prime)):
		if prime[p]:
			li.append(p)
	return li

def primefactors(n):
	factors = []
	while n % 2 == 0:
		factors.append(2)
		n //= 2
	for i in range(3, int(sqrt(n)) + 1, 2):
		while n % i == 0:
			factors.append(i)
			n //= i
	if n > 2:
		factors.append(n)
	return factors

def prod(li):
	ans = 1
	for i in li:
		ans *= i
	return ans

def dist(a, b):
	d = abs(a[1] - b[1]) + abs(a[2] - b[2])
	return d

def power_of_n(x, n):
	cnt = 0
	while x % n == 0:
		cnt += 1
		x //= n
	return cnt

def check(u, r, d, l):
	f = 1
	if u == 0 or d == 0:
		if l == n or r == n:
			f = 0
	if l == 0 or r == 0:
		if d == n or u == n:
			f = 0
	if u == 0 and d == 0:
		if l >= n - 1 or r >= n - 1:
			f = 0
	if l == 0 and r == 0:
		if d >= n - 1 or u >= n - 1:
			f = 0
	return f
for _ in range(1):
	n = int(input())
	a = list(map(int, input().split()))
	dp = [[0, 0, 0]] * (n + 1)
	for i in range(1, n + 1):
		dp[i] = [min(dp[i - 1]) + 1] + dp[i][1:]
		if a[i - 1] == 0:
			dp[i][1] = dp[i - 1][1] + 1
			dp[i][2] = dp[i - 1][2] + 1
		elif a[i - 1] == 1:
			dp[i][1] = min(dp[i - 1][0], dp[i - 1][2])
			dp[i][2] = dp[i - 1][2] + 1
		elif a[i - 1] == 2:
			dp[i][1] = dp[i - 1][1] + 1
			dp[i][2] = min(dp[i - 1][0], dp[i - 1][1])
		else:
			dp[i][1] = min(dp[i - 1][0], dp[i - 1][2])
			dp[i][2] = min(dp[i - 1][0], dp[i - 1][1])
	print(min(dp[-1]))


n = int(input())
arr = list(map(int, input().split()))
ans = [[0 for i in range(3)] for j in range(n + 1)]
for i in range(1, n + 1):
	ans[i][0] = max(ans[i - 1])
	if arr[i - 1] == 1 or arr[i - 1] == 3:
		ans[i][1] = max(ans[i - 1][0] + 1, ans[i - 1][2] + 1)
	if arr[i - 1] == 2 or arr[i - 1] == 3:
		ans[i][2] = max(ans[i - 1][0] + 1, ans[i - 1][1] + 1)
maximum = 0
for i in ans:
	x = max(i)
	if x > maximum:
		maximum = x
print(n - maximum)


n = int(input())
l = list(map(int, input().split()))
dp = [[0, 0, 0] for i in range(n + 1)]
for i in range(1, n + 1):
	dp[i][0] = max(dp[i - 1])
	if l[i - 1] == 3:
		dp[i][1] = max(dp[i - 1][0] + 1, dp[i - 1][2] + 1)
		dp[i][2] = max(dp[i - 1][0] + 1, dp[i - 1][1] + 1)
	elif l[i - 1] == 2:
		dp[i][2] = max(dp[i - 1][0] + 1, dp[i - 1][1] + 1)
	elif l[i - 1] == 1:
		dp[i][1] = max(dp[i - 1][0] + 1, dp[i - 1][2] + 1)
print(n - max(dp[n]))


n = int(input())
alist = list(map(int, input().split()))
dp = [[101 for _ in range(3)] for _ in range(n + 1)]
for i in range(3):
	dp[0][i] = 0
for i in range(1, n + 1):
	dp[i][0] = min([dp[i - 1][0], dp[i - 1][1], dp[i - 1][2]]) + 1
	if alist[i - 1] == 1:
		dp[i][2] = min(dp[i - 1][0], dp[i - 1][1])
	elif alist[i - 1] == 2:
		dp[i][1] = min(dp[i - 1][0], dp[i - 1][2])
	elif alist[i - 1] == 3:
		dp[i][1] = min(dp[i - 1][0], dp[i - 1][2])
		dp[i][2] = min(dp[i - 1][0], dp[i - 1][1])
print(min([dp[n][0], dp[n][1], dp[n][2]]))


n = int(input())
a = list(map(int, input().split()))
mem = {}

def solve(i, previous):
	if i == n:
		return 0
	if a[i] == 0 or a[i] == previous:
		return solve(i + 1, 0) + 1
	elif a[i] == 3:
		if previous == 0:
			return solve(i + 1, 0)
		return solve(i + 1, 2 if previous == 1 else 1)
	return solve(i + 1, a[i])
print(solve(0, 0))


from collections import Counter
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')
import sys
import sys
import math
n = int(input())
inf = 1000
dp = [[inf, inf, inf] for i in range(n)]
arr = list(map(int, input().split()))
dp[0][0] = 1
dp[0][1] = 0 if arr[0] == 2 or arr[0] == 3 else inf
dp[0][2] = 0 if arr[0] == 1 or arr[0] == 3 else inf
for i in range(1, n):
	dp[i][0] = min(dp[i - 1][0], dp[i - 1][1], dp[i - 1][2]) + 1
	if arr[i] == 1 or arr[i] == 3:
		dp[i][2] = min(dp[i - 1][1], dp[i - 1][0])
	if arr[i] == 2 or arr[i] == 3:
		dp[i][1] = min(dp[i - 1][2], dp[i - 1][0])
print(min(dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]))


(n, vr, vg, vc) = (int(input()), 0, 0, 0)
for x in map(int, input().split()):
	cr = min(vr, vg, vc) + 1
	cg = min(vr, vc) if x & 2 else n
	cc = min(vr, vg) if x & 1 else n
	(vr, vg, vc) = (cr, cg, cc)
print(min(vr, vg, vc))


n = int(input())
l = list(map(int, input().split()))
cur = ans = 0
for a in l:
	if a == 0:
		ans += 1
		cur = 0
	elif a == 1:
		if cur in (0, 1):
			cur = 2
		else:
			ans += 1
			cur = 0
	elif a == 2:
		if cur in (0, 2):
			cur = 1
		else:
			ans += 1
			cur = 0
	else:
		cur = [0, 2, 1][cur]
print(ans)


from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

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

def iinp():
	return int(inp())

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

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

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

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

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

def remadd(x, y):
	return 1 if x % y else 0

def ceil(a, b):
	return (a + b - 1) // b
S1 = 'abcdefghijklmnopqrstuvwxyz'
S2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
n = iinp()
arr = lmp()
dp = l2d(n + 1, 3, inf)
for i in range(3):
	dp[0][i] = 0
for i in range(1, n + 1):
	if arr[i - 1] == 1:
		dp[i][1] = min(dp[i - 1][0], dp[i - 1][2])
	elif arr[i - 1] == 2:
		dp[i][2] = min(dp[i - 1][0], dp[i - 1][1])
	elif arr[i - 1] == 3:
		dp[i][1] = min(dp[i - 1][0], dp[i - 1][2])
		dp[i][2] = min(dp[i - 1][0], dp[i - 1][1])
	dp[i][0] = min(dp[i - 1]) + 1
print(min(dp[n]))


import sys
import math
import collections
import heapq
input = sys.stdin.readline
n = int(input())
l = [int(i) for i in input().split()]
c = 0
dp = []
for i in range(n + 1):
	l1 = [0, 0]
	dp.append(l1)
for i in range(n):
	if l[i] == 0:
		dp[i + 1][0] = min(dp[i][0] + 1, dp[i][1] + 1)
		dp[i + 1][1] = min(dp[i][0] + 1, dp[i][1] + 1)
	elif l[i] == 1:
		dp[i + 1][0] = min(dp[i][0] + 1, dp[i][1] + 1)
		dp[i + 1][1] = min(dp[i][0], dp[i][1] + 1)
	elif l[i] == 2:
		dp[i + 1][0] = min(dp[i][0] + 1, dp[i][1])
		dp[i + 1][1] = min(dp[i][0] + 1, dp[i][1] + 1)
	else:
		dp[i + 1][0] = min(dp[i][0] + 1, dp[i][1])
		dp[i + 1][1] = min(dp[i][0], dp[i][1] + 1)
print(min(dp[n][0], dp[n][1]))


n = int(input())
l_n = list(map(int, input().split()))
p = l_n[0]
t = 1 if p == 0 else 0
for i in range(1, n):
	if l_n[i] == p and p != 3:
		l_n[i] = 0
	elif l_n[i] == 3 and p != 3:
		l_n[i] -= p
	if l_n[i] == 0:
		t += 1
	p = l_n[i]
print(t)


n = int(input())
a = list(map(int, input().split()))
dp = [-1 for i in range(n)]
dp[0] = a[0]
for i in range(1, n):
	if a[i] == 0:
		dp[i] = 0
	elif a[i] == dp[i - 1] and a[i] != 3:
		dp[i] = 0
	elif a[i] == 3 and dp[i - 1] != 3:
		dp[i] = abs(3 - dp[i - 1])
	else:
		dp[i] = a[i]
print(dp.count(0))


n = int(input())
l = [int(x) for x in input().split()]
dp = [[0 for _ in range(3)] for _ in range(len(l))]
for i in range(len(l)):
	if i == 0:
		if l[i] == 1:
			dp[i][1] = 1
		elif l[i] == 2:
			dp[i][2] = 1
		elif l[i] == 3:
			dp[i][1] = 1
			dp[i][2] = 1
		continue
	if l[i] == 0:
		dp[i][0] = max(dp[i - 1][0], dp[i - 1][1], dp[i - 1][2])
	if l[i] == 1:
		dp[i][0] = max(dp[i - 1][0], dp[i - 1][1], dp[i - 1][2])
		dp[i][1] = max(dp[i - 1][0] + 1, dp[i - 1][1], dp[i - 1][2] + 1)
		dp[i][2] = 0
	if l[i] == 2:
		dp[i][0] = max(dp[i - 1][0], dp[i - 1][1], dp[i - 1][2])
		dp[i][1] = 0
		dp[i][2] = max(dp[i - 1][0] + 1, dp[i - 1][1] + 1, dp[i - 1][2])
	if l[i] == 3:
		dp[i][0] = max(dp[i - 1][0], dp[i - 1][1], dp[i - 1][2])
		dp[i][1] = max(dp[i - 1][0] + 1, dp[i - 1][1], dp[i - 1][2] + 1)
		dp[i][2] = max(dp[i - 1][0] + 1, dp[i - 1][1] + 1, dp[i - 1][2])
print(len(l) - max(dp[-1]))


a = input()
z = list(map(int, input().split()))
count = 0
if z[0] == 0:
	count = 1
for i in range(1, len(z)):
	if z[i] == 0:
		count = count + 1
	elif z[i] == 3:
		if z[i - 1] == 1:
			z[i] = 2
		elif z[i - 1] == 2:
			z[i] = 1
	elif z[i] == z[i - 1] and z[i] != 3:
		count = count + 1
		z[i] = 0
print(count)


n = int(input())
a = list(map(int, input().split(' ')))
l = [3, 2, 1, 3]
rest = 0
last = 0
for i in range(n):
	if a[i] == 0:
		rest += 1
		last = 0
	elif a[i] == 3:
		last = l[last]
	elif last == a[i]:
		rest += 1
		last = 0
	else:
		last = a[i]
print(rest)


def read_line():
	return input().strip()

def read_int():
	return int(read_line())

def read_int_array():
	return [int(i) for i in read_line().split(' ')]

def read_string_array():
	return [i for i in read_line().split(' ')]
T = read_int()
D = read_int_array()
AD = [-1] * len(D)
AD[0] = D[0]
rests = 1 if AD[0] == 0 else 0
for i in range(1, len(D)):
	if D[i] == 0:
		rests += 1
		AD[i] = 0
	elif D[i] == 1:
		if AD[i - 1] == 1:
			rests += 1
			AD[i] = 0
		else:
			AD[i] = 1
	elif D[i] == 2:
		if AD[i - 1] == 2:
			rests += 1
			AD[i] = 0
		else:
			AD[i] = 2
	elif D[i] == 3:
		if AD[i - 1] == 3:
			AD[i] = 3
		else:
			AD[i] = D[i] - AD[i - 1]
print(rests)


n = int(input())
a = list(map(int, input().split()))
memo = [[-1] * 4 for i in range(n)]

def dp(i, prev):
	if i == n:
		return 0
	if memo[i][prev] == -1:
		memo[i][prev] = 1 + dp(i + 1, 0)
		if a[i] == 1 or a[i] == 2:
			if a[i] != prev:
				memo[i][prev] = min(memo[i][prev], dp(i + 1, a[i]))
		elif a[i] == 3:
			for x in range(1, 3):
				if x != prev:
					memo[i][prev] = min(memo[i][prev], dp(i + 1, x))
	return memo[i][prev]
print(dp(0, 0))


import sys, os.path
from collections import *
from copy import *
import math
mod = 10 ** 9 + 7
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def solve(i, sport, contest):
	if i == n:
		return 0
	if dp[i][sport][contest] != -1:
		return dp[i][sport][contest]
	ans = 0
	if a[i] == 0:
		ans = 1 + solve(i + 1, 0, 0)
	elif a[i] == 1:
		if contest:
			ans = 1 + solve(i + 1, 0, 0)
		else:
			ans = min(1 + solve(i + 1, 0, 0), solve(i + 1, 0, 1))
	elif a[i] == 2:
		if sport:
			ans = 1 + solve(i + 1, 0, 0)
		else:
			ans = min(1 + solve(i + 1, 0, 0), solve(i + 1, 1, 0))
	elif sport:
		ans = min(1 + solve(i + 1, 0, 0), solve(i + 1, 0, 1))
	elif contest:
		ans = min(1 + solve(i + 1, 0, 0), solve(i + 1, 1, 0))
	else:
		ans = min(solve(i + 1, 0, 1), solve(i + 1, 1, 0), 1 + solve(i + 1, 0, 0))
	dp[i][sport][contest] = ans
	return dp[i][sport][contest]
n = int(input())
a = list(map(int, input().split()))
dp = [[[-1 for k in range(3)] for j in range(3)] for i in range(105)]
print(solve(0, 0, 0))


n = int(input())
numbers = list(map(int, input().split(' ')))
memo = [[0 for _ in range(4)] for _ in range(n)]
first = numbers[0]
if first != 0:
	if first == 3:
		memo[0][1] = 1
		memo[0][2] = 1
	else:
		memo[0][first] = 1
for i in range(1, n):
	j = numbers[i]
	memo[i][0] = max(memo[i - 1])
	if j == 1 or j == 3:
		memo[i][1] = max(memo[i - 1][2], memo[i - 1][0]) + 1
	if j == 2 or j == 3:
		memo[i][2] = max(memo[i - 1][1], memo[i - 1][0]) + 1
print(n - max(memo[n - 1]))


n = int(input())
a = list(map(int, input().split(' ')))
(code, sport) = ([0] * n, [0] * n)
for i in range(n):
	code[i] = max(code[i], a[i] % 2)
	sport[i] = max(sport[i], a[i] // 2)
	for j in range(i + 1, n):
		if a[j] % 2:
			code[j] = max(code[j], sport[i] + 1)
		if a[j] // 2:
			sport[j] = max(sport[j], code[i] + 1)
	for j in range(i + 2, n):
		if a[j] % 2:
			code[j] = max(code[j], code[i] + 1)
		if a[j] // 2:
			sport[j] = max(sport[j], sport[i] + 1)
result = n - max(max(code), max(sport))
print(result)


import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
dp = [[0 for i in range(3)] for j in range(n)]
dp[0][0] = 0
if a[0] == 1 or a[0] == 3:
	dp[0][1] = 1
if a[0] == 2 or a[0] == 3:
	dp[0][2] = 1
for i in range(1, n):
	dp[i][0] = max(dp[i - 1])
	if a[i] == 1 or a[i] == 3:
		dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + 1
	if a[i] == 2 or a[i] == 3:
		dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + 1
m = 0
for i in dp:
	m = max(m, max(i))
print(n - m)


n = int(input())
lst = [int(i) for i in input().split()]
(result, previous) = (0, 0)
for elem in lst:
	if elem == previous or elem == 0:
		previous = 0
		result += 1
	elif elem == 1 or elem == 2:
		previous = elem
	elif previous > 0 and elem == 3:
		previous = 3 - previous
print(result)


def min_rest_days(days):
	cache = {-1: [0, 0, 0]}
	for i in range(len(days)):
		prev_cache = cache[i - 1]
		if days[i] == 0:
			cache[i] = [float('inf'), float('inf'), min(prev_cache[0], prev_cache[1], prev_cache[2]) + 1]
		elif days[i] == 1:
			if i > 0 and days[i] == days[i - 1]:
				prev_min = prev_cache[2]
			else:
				prev_min = min(prev_cache[0], prev_cache[2])
			cache[i] = [float('inf'), prev_min, min(prev_cache[0], prev_cache[1], prev_cache[2]) + 1]
		elif days[i] == 2:
			if i > 0 and days[i] == days[i - 1]:
				prev_min = prev_cache[2]
			else:
				prev_min = min(prev_cache[1], prev_cache[2])
			cache[i] = [prev_min, float('inf'), min(prev_cache[0], prev_cache[1], prev_cache[2]) + 1]
		elif days[i] == 3:
			first = min(prev_cache[1], prev_cache[2])
			second = min(prev_cache[0], prev_cache[2])
			if i > 0:
				if days[i - 1] == 1:
					second = prev_cache[2]
				elif days[i - 1] == 2:
					first = prev_cache[2]
			cache[i] = [first, second, min(prev_cache[0], prev_cache[1], prev_cache[2]) + 1]
	return min(cache[len(days) - 1])
_ = input()
days = [int(el) for el in input().split()]
print(min_rest_days(days))


elem = int(input())
ar = []
for i in input().split(' '):
	ar.append(int(i))
res = [0]
cont = [0]
gym = [0]
for i in ar:
	if i == 0:
		res.append(min(res[-1], cont[-1], gym[-1]) + 1)
		cont.append(cont[-1] + 1)
		gym.append(gym[-1] + 1)
	elif i == 1:
		temp = min(res[-1], cont[-1], gym[-1]) + 1
		temp2 = min(gym[-1], res[-1])
		temp3 = gym[-1] + 1
		res.append(temp)
		cont.append(temp2)
		gym.append(temp3)
	elif i == 2:
		temp = min(res[-1], cont[-1], gym[-1]) + 1
		temp2 = cont[-1] + 1
		temp3 = min(cont[-1], res[-1])
		res.append(temp)
		cont.append(temp2)
		gym.append(temp3)
	else:
		temp = min(res[-1], cont[-1], gym[-1]) + 1
		temp2 = min(gym[-1], res[-1])
		temp3 = min(cont[-1], res[-1])
		res.append(temp)
		cont.append(temp2)
		gym.append(temp3)
print(min(res[-1], cont[-1], gym[-1]))


n = int(input())
s = input()
A = []
Sum = 0
F = 0
for i in s.split():
	A.append(int(i))
for j in range(0, n):
	if A[j] == 0:
		Sum = Sum + 1
		F = 0
	elif A[j] == 1:
		if F == 0:
			F = 1
		elif F == 1:
			Sum = Sum + 1
			F = 0
		elif F == 2:
			F = 1
	elif A[j] == 2:
		if F == 0:
			F = 2
		elif F == 1:
			F = 2
		elif F == 2:
			Sum = Sum + 1
			F = 0
	elif A[j] == 3:
		if F == 0:
			F = 0
		elif F == 1:
			F = 2
		elif F == 2:
			F = 1
print(Sum)


n = int(input())
days = list(map(int, input().split()))
dp = [[999, 999, 999] for x in range(100)]
dp[0][0] = 1
if days[0] == 1:
	dp[0][1] = 0
elif days[0] == 2:
	dp[0][2] = 0
elif days[0] == 3:
	dp[0][1] = 0
	dp[0][2] = 0
for i in range(1, n):
	dp[i][0] = 1 + min(dp[i - 1][0], dp[i - 1][1], dp[i - 1][2])
	if days[i] == 1:
		dp[i][1] = min(dp[i - 1][0], dp[i - 1][2])
	elif days[i] == 2:
		dp[i][2] = min(dp[i - 1][0], dp[i - 1][1])
	elif days[i] == 3:
		dp[i][1] = min(dp[i - 1][0], dp[i - 1][2])
		dp[i][2] = min(dp[i - 1][0], dp[i - 1][1])
print(min(dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]))


def val(a, action):
	res = 1000
	if a == 3:
		res = 0
	elif a == 1 and action == 'C':
		res = 0
	elif a == 2 and action == 'G':
		res = 0
	return res
n = int(input())
a = list(map(int, input().split()))
curr = {}
prev = {'G': 0, 'C': 0, 'R': 0}
for i in a:
	curr['G'] = min(prev['C'], prev['R']) + val(i, 'G')
	curr['C'] = min(prev['G'], prev['R']) + val(i, 'C')
	curr['R'] = min(prev['C'], prev['G'], prev['R']) + 1
	prev = curr.copy()
print(min(prev.values()))


n = int(input())
dias = list(map(int, input().split()))
OPT = [[0] * 3 for i in range(2)]
for i in range(n):
	if dias[i] == 0:
		optimo_anterior = 1 + OPT[0][0]
		OPT[1][0] = optimo_anterior
		OPT[1][1] = optimo_anterior
		OPT[1][2] = optimo_anterior
	elif dias[i] == 1:
		optimo_anterior = min(OPT[0][0] + 1, OPT[0][2])
		OPT[1][0] = optimo_anterior
		OPT[1][1] = optimo_anterior
		OPT[1][2] = 1 + OPT[0][0]
	elif dias[i] == 2:
		optimo_anterior = min(OPT[0][0] + 1, OPT[0][1])
		OPT[1][0] = optimo_anterior
		OPT[1][2] = optimo_anterior
		OPT[1][1] = 1 + OPT[0][0]
	else:
		OPT[1][0] = min(OPT[0][0] + 1, OPT[0][1], OPT[0][2])
		OPT[1][1] = min(OPT[0][0] + 1, OPT[0][2])
		OPT[1][2] = min(OPT[0][0] + 1, OPT[0][1])
	OPT[0][0] = OPT[1][0]
	OPT[0][1] = OPT[1][1]
	OPT[0][2] = OPT[1][2]
print(OPT[1][0])


n = int(input())
l = list(map(int, input().split()))
output = 1 if l[0] == 0 else 0
u = False
for i in range(1, n):
	if l[i] == 0:
		output += 1
	elif l[i] == l[i - 1] and l[i] != 3:
		output += 1
		l[i] = 0
	elif l[i] == 3:
		if l[i - 1] == 1:
			l[i] = 2
		elif l[i - 1] == 2:
			l[i] = 1
print(output)


import sys

def minrest(v, n, i, last):
	if i >= n:
		return 0
	if dp[i][last] != -1:
		return dp[i][last]
	if v[i] == 0:
		dp[i][last] = minrest(v, n, i + 1, 0) + 1
	elif v[i] == 1:
		if v[i] == last:
			dp[i][last] = minrest(v, n, i + 1, 0) + 1
		else:
			dp[i][last] = minrest(v, n, i + 1, 1)
	elif v[i] == 2:
		if v[i] == last:
			dp[i][last] = minrest(v, n, i + 1, 0) + 1
		else:
			dp[i][last] = minrest(v, n, i + 1, 2)
	elif v[i] == 3:
		if last == 1:
			a = sys.maxsize
		else:
			a = minrest(v, n, i + 1, 1)
		if last == 2:
			b = sys.maxsize
		else:
			b = minrest(v, n, i + 1, 2)
		dp[i][last] = min(a, b)
	return dp[i][last]
dp = [[-1] * 3 for i in range(105)]
n = int(input())
v = list(map(int, input().split()))
ans = minrest(v, n, 0, 0)
print(ans)


n = int(input())
a = list(map(int, input().split()))
cnt = 0
last = a[0]
if last == 3:
	last = 5
if a[0] != 0:
	cnt += 1
for i in range(1, n):
	if a[i] != last and a[i] != 0:
		if a[i] == 3:
			if last == 0 or last == 5:
				last = 5
				cnt += 1
			else:
				last = abs(last - 3)
				cnt += 1
		else:
			last = a[i]
			cnt += 1
	else:
		last = 0
print(n - cnt)


for t in range(1):
	n = int(input())
	arr = list(map(int, input().split()))
	prev = arr[0]
	if prev == 0:
		count = 1
	else:
		count = 0
	for ele in range(1, n):
		i = arr[ele]
		if i == 0:
			count += 1
			prev = 0
			continue
		elif i == 1:
			if prev == 1:
				prev = 0
				count += 1
				continue
			else:
				prev = 1
				continue
		elif i == 2:
			if prev == 2:
				prev = 0
				count += 1
				continue
			else:
				prev = 2
				continue
		elif i == 3:
			if prev == 1:
				prev = 2
				continue
			elif prev == 2:
				prev = 1
				continue
			else:
				prev = 0
				continue
	print(count)


int(input())
descanso = anterior = 0
for i in [int(k) for k in input().split()]:
	if i == 0 or i == anterior:
		descanso += 1
		anterior = 0
	elif i == 3:
		if anterior != 0:
			anterior = 3 - anterior
	else:
		anterior = i
print(descanso)


import sys
import math
inf = 100000000
n = int(input())
a = [int(e) for e in input().split()]
f = [[0, 0, 0] for i in range(n)]
m = inf
f[0][0] = 1
if a[0] == 1 or a[0] == 3:
	f[0][1] = 0
else:
	f[0][1] = inf
if a[0] == 2 or a[0] == 3:
	f[0][2] = 0
else:
	f[0][2] = inf
if a[0] == 0:
	f[0][1] = f[0][2] = inf
m = min(f[0])
for i in range(1, n):
	f[i][0] = min(f[i - 1]) + 1
	if a[i] == 1 or a[i] == 3:
		f[i][1] = min(f[i - 1][0], f[i - 1][2])
	else:
		f[i][1] = inf
	if a[i] == 2 or a[i] == 3:
		f[i][2] = min(f[i - 1][0], f[i - 1][1])
	else:
		f[i][2] = inf
	if a[i] == 0:
		f[i][1] = f[i][2] = inf
	m = min(f[i])
print(m)


def f(arr):
	prev_contest = float('-inf')
	prev_gym = float('-inf')
	prev_none = 0
	for a in arr:
		contest = prev_contest
		gym = prev_gym
		none = prev_none
		if a & 1:
			contest = max(prev_gym + 1, prev_none + 1)
		if a & 2:
			gym = max(prev_contest + 1, prev_none + 1)
		none = max(prev_contest, prev_gym, prev_none)
		prev_none = none
		prev_contest = contest
		prev_gym = gym
	res = len(arr) - max(prev_none, prev_contest, prev_gym)
	return res
assert f([1]) == 0
assert f([2]) == 0
assert f([3]) == 0
assert f([1, 2]) == 0
assert f([1, 3]) == 0
assert f([1, 1]) == 1
assert f([1, 3, 2]) == 1
assert f([2, 3, 1]) == 1
assert f([1, 3, 2, 0]) == 2
assert f([1, 3, 3, 2, 1, 2, 3]) == 0
assert f([2, 2]) == 1
X100 = [3, 2, 3, 3, 3, 2, 3, 1, 3, 2, 2, 3, 2, 3, 3, 3, 3, 3, 3, 1, 2, 2, 3, 1, 3, 3, 2, 2, 2, 3, 1, 0, 3, 3, 3, 2, 3, 3, 1, 1, 3, 1, 3, 3, 3, 1, 3, 1, 3, 0, 1, 3, 2, 3, 2, 1, 1, 3, 2, 3, 3, 3, 2, 3, 1, 3, 3, 3, 3, 2, 2, 2, 1, 3, 1, 3, 3, 3, 3, 1, 3, 2, 3, 3, 0, 3, 3, 3, 3, 3, 1, 0, 2, 1, 3, 3, 0, 2, 3, 3]
assert len(X100) == 100
assert f(X100) == 16
n = int(input())
A = map(int, input().split())
ans = f(list(A))
print(ans)


n = int(input())
a = list(map(int, input().split()))
cnt = 0
x = 0
for i in range(n):
	if a[i] != 3:
		x = i
		break
for i in range(x, n):
	if a[i] == 0:
		cnt += 1
	if i > 0 and a[i] == 2 and (a[i - 1] == 2):
		a[i] = 0
		cnt += 1
	if i > 0 and a[i] == 1 and (a[i - 1] == 1):
		a[i] = 0
		cnt += 1
	if a[i] == 3 and a[i - 1] == 1:
		a[i] = 2
	if a[i] == 3 and a[i - 1] == 2:
		a[i] = 1
print(cnt)


import sys
inp = sys.stdin
n = int(inp.readline())
a = list(map(int, inp.readline().split()))
best = [0, 0, 0]
for i in range(n):
	nx_best = [0, 0, 0]
	if a[i] in (1, 3):
		nx_best[1] = max(best[0], best[2]) + 1
	if a[i] in (2, 3):
		nx_best[2] = max(best[0], best[1]) + 1
	nx_best[0] = max(best)
	best = nx_best[:]
print(n - max(best))


import sys
import math
import bisect
from math import sqrt

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

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

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

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
mod = int(1000000000.0) + 7

def greedyApproach():
	rest = 0
	last = -1
	for i in range(n):
		if a[i] == 0 or a[i] == last:
			rest += 1
			last = 0
		elif a[i] == 3:
			if last == 1:
				last = 2
			elif last == 2:
				last = 1
		else:
			last = a[i]
	return rest

def dpApproach():
	dp = [[sys.maxsize for _ in range(3)] for _ in range(100)]
	dp[0][0] = 1
	if a[0] == 1 or a[0] == 3:
		dp[0][1] = 0
	if a[0] == 2 or a[0] == 3:
		dp[0][2] = 0
	for i in range(1, n):
		dp[i][0] = 1 + min(dp[i - 1][0], min(dp[i - 1][1], dp[i - 1][2]))
		if a[i] == 3:
			dp[i][1] = min(dp[i - 1][0], dp[i - 1][2])
			dp[i][2] = min(dp[i - 1][0], dp[i - 1][1])
		elif a[i] == 1:
			dp[i][1] = min(dp[i - 1][0], dp[i - 1][2])
		elif a[i] == 2:
			dp[i][2] = min(dp[i - 1][0], dp[i - 1][1])
	return min(dp[n - 1][0], min(dp[n - 1][1], dp[n - 1][2]))
n = iinput()
a = get_list()
print(dpApproach())


n = int(input())
ans = [0] + list(map(int, input().split()))
lis = ['@'] * (n + 1)
i = 1
while i < n + 1:
	if ans[i] == 0:
		lis[i] = 'r'
	elif ans[i] == 1:
		if lis[i - 1] == 'c':
			lis[i] = 'r'
		else:
			lis[i] = 'c'
	elif ans[i] == 2:
		if lis[i - 1] == 'g':
			lis[i] = 'r'
		else:
			lis[i] = 'g'
	elif lis[i - 1] == 'g':
		lis[i] = 'c'
	elif lis[i - 1] == 'c':
		lis[i] = 'g'
	else:
		while i + 1 <= n and ans[i + 1] == 3:
			i += 1
		if i <= n and ans[i] == 2:
			lis[i] = 'g'
		elif i <= n and ans[i] == 1:
			lis[i] = 'c'
		elif i <= n and ans[i] == 0:
			lis[i] = 'r'
	i += 1
aa = 0
for i in lis[1:]:
	if i == 'r':
		aa += 1
print(aa)


n = int(input())
l = list(map(int, input().split()))
r = 0
x = 0
for i in range(len(l)):
	if l[i] == 0 or l[i] == x:
		r += 1
		x = 0
	elif l[i] == 3:
		if x != 0:
			x = 3 - x
	else:
		x = l[i]
print(r)


log = lambda *x: print(*x)

def cin(*fn, def_fn=str):
	(i, r) = (0, [])
	for c in input().split(' '):
		r += [(fn[i] if len(fn) > i else fn[0])(c)]
		i += 1
	return r
INF = 1 << 33

def solve(a, n):
	dp = []
	for i in range(n + 1):
		dp += [[]]
		for j in range(n + 1):
			dp[i] += [{1: 0, 10: 0, 11: 0}]
	for i in range(n, -1, -1):
		for t in range(n - 1, -1, -1):
			for tf in [11, 10, 1]:
				if i == n:
					dp[i][t][tf] = i - t
					continue
				cc = tf // 10 and (a[i] == 1 or a[i] == 3)
				cg = tf % 10 and (a[i] == 2 or a[i] == 3)
				if not (cc or cg):
					dp[i][t][tf] = dp[i + 1][t][11]
					continue
				(a1, a2) = (INF, INF)
				if cc:
					a1 = dp[i + 1][t + 1][1]
				if cg:
					a2 = dp[i + 1][t + 1][10]
				dp[i][t][tf] = min(a1, a2)
	return min(dp[0][0][1], dp[0][0][10])
(n,) = cin(int)
a = cin(int)
log(solve(a, n))


n = int(input())
k = list(map(int, input().split(' ')))
ans = 0
last = 'n'
for i in k:
	if i == 0:
		now = 'n'
	elif i == 1 and last != 'p':
		now = 'p'
	elif i == 1:
		now = 'n'
	elif i == 2 and last != 's':
		now = 's'
	elif i == 2:
		now = 'n'
	elif last == 's':
		now = 'p'
	elif last == 'p':
		now = 's'
	else:
		now = 'a'
	if now == 'n':
		ans += 1
	last = now
print(ans)


def rev(a):
	if a == 1:
		return 2
	return 1

def solve(n, s):
	prev = 0
	for i in range(n):
		if s[i] == 3 and prev == 0:
			k = 0
			for j in range(i, n):
				k = j - 1
				if s[j] != 3:
					break
			for j in range(k, i - 1, -1):
				s[j] = rev(s[j + 1])
		elif i != 0:
			if s[i] == 3:
				s[i] = rev(s[i - 1])
			elif s[i] == 0:
				s[i] = 0
			elif s[i] == s[i - 1]:
				s[i] = 0
		prev = s[i]
	return s.count(0)
n = int(input())
li = list(map(int, input().split()))
print(solve(n, li))


n = int(input())
mas = list(map(int, input().split()))
i = 1
e = mas[0]
if e == 0:
	res = 1
else:
	res = 0
if e == 3:
	for (i, x) in enumerate(mas):
		if x != 3:
			break
	if mas[i] == 3:
		print(0)
		from sys import exit
		exit()
	if mas[i] == 2:
		e = 1
	else:
		e = 2
for k in range(i, n):
	r = mas[k]
	if r == 0:
		res += 1
		e = 0
		continue
	if e != 3:
		if r == 3:
			if e == 1:
				e = 2
			elif e == 2:
				e = 1
			else:
				e = 3
		elif e == r:
			e = 0
			res += 1
		else:
			e = r
	else:
		e = r
print(res)


n = int(input())
a = list(map(int, input().split()))
c = ct = gm = 0
for i in range(n):
	if a[i] == 0:
		ct = 0
		gm = 0
		c += 1
	elif a[i] == 1 and ct == 0:
		ct = 1
		gm = 0
	elif a[i] == 2 and gm == 0:
		gm = 1
		ct = 0
	elif a[i] == 3:
		if ct == 1:
			ct = 0
			gm = 1
		elif gm == 1:
			gm = 0
			ct = 1
	else:
		ct = 0
		gm = 0
		c += 1
print(c)


n = int(input())
ls = list(map(int, input().split()))
ary = [[0, 0, 0] for j in range(n + 1)]
for i in range(1, n + 1):
	ma = max(ary[i - 1])
	ary[i][0] = ma
	ary[i][1] = max(ary[i - 1][0], ary[i - 1][2]) + (ls[i - 1] == 1 or ls[i - 1] == 3)
	ary[i][2] = max(ary[i - 1][0], ary[i - 1][1]) + (ls[i - 1] == 2 or ls[i - 1] == 3)
print(n - max(ary[-1]))


n = int(input())
days = list(map(int, input().split()))
(res, prev) = (0, 3)
for d in days:
	if prev != 3:
		if d == prev:
			d = 0
		elif d == 3:
			d -= prev
	if d == 0:
		res += 1
	prev = d
print(res)


n = int(input())
l = list(map(int, input().split()))
if n == 1:
	if l[0] == 0:
		print(1)
	else:
		print(0)
else:
	dp = [[float('inf') for i in range(3)] for j in range(n)]
	for i in range(n):
		for j in range(3):
			if i == 0:
				dp[i][0] = 1
				if l[i] == 1:
					dp[i][1] = 0
				elif l[i] == 2:
					dp[i][2] = 0
				elif l[i] == 3:
					dp[i][1] = 0
					dp[i][2] = 0
			else:
				dp[i][0] = 1 + min(dp[i - 1])
				if l[i] == 1:
					dp[i][1] = min(dp[i - 1][0], dp[i - 1][2])
				elif l[i] == 2:
					dp[i][2] = min(dp[i - 1][0], dp[i - 1][1])
				elif l[i] == 3:
					dp[i][1] = min(dp[i - 1][0], dp[i - 1][2])
					dp[i][2] = min(dp[i - 1][0], dp[i - 1][1])
	print(min(dp[-1]))


import sys
import math
import bisect
from math import sqrt

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

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

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

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
mod = int(1000000000.0) + 7
n = iinput()
a = get_list()
rest = 0
last = -1
for i in range(n):
	if a[i] == 0 or a[i] == last:
		rest += 1
		last = 0
	elif a[i] == 3:
		if last == 1:
			last = 2
		elif last == 2:
			last = 1
	else:
		last = a[i]
print(rest)


n = int(input())
arr = []
p = list(map(int, input().split()))
for i in range(n):
	arr.append([10000, 10000, 10000, p[i]])
arr[0][0] = 1
if arr[0][3] == 1 or arr[0][3] == 3:
	arr[0][1] = 0
if arr[0][3] == 2 or arr[0][3] == 3:
	arr[0][2] = 0
for i in range(1, n):
	arr[i][0] = 1 + min(arr[i - 1][0], arr[i - 1][1], arr[i - 1][2])
	if arr[i][3] == 1 or arr[i][3] == 3:
		arr[i][1] = min(arr[i - 1][0], arr[i - 1][2])
	if arr[i][3] == 2 or arr[i][3] == 3:
		arr[i][2] = min(arr[i - 1][0], arr[i - 1][1])
least = 10000
for i in range(0, 3):
	least = min(least, arr[n - 1][i])
print(least)


n = int(input())
ai = list(map(int, input().split()))
for i in range(n):
	if i < n - 1:
		if ai[i] % 3 != 0 and ai[i] == ai[i + 1]:
			ai[i + 1] = 0
		elif ai[i + 1] == 3 and ai[i] % 3 != 0:
			ai[i + 1] = 3 - ai[i]
	ai[i] = int(ai[i] > 0)
print(n - sum(ai))


n = int(input())
x = [int(x) for x in input().split()]
x.append(-1)
rest = 0
if x[0] == 0:
	rest = rest + 1
for i in range(1, n):
	if x[i] == 0:
		rest = rest + 1
	elif x[i] == 1 and x[i - 1] == 1:
		rest = rest + 1
		x[i] = 0
	elif x[i] == 2 and x[i - 1] == 2:
		rest = rest + 1
		x[i] = 0
	elif x[i] == 3:
		if x[i - 1] == 1:
			x[i] = 2
		elif x[i - 1] == 2:
			x[i] = 1
		elif x[i - 1] == 0 and x[i + 1] == 2:
			x[i] == 1
		elif x[i - 1] == 0 and x[i + 1] == 1:
			x[i] == 2
print(rest)


def __starting_point():
	MAX = 100
	n = int(input())
	num = list()
	for i in range(n + 1):
		num.append([0, 0, 0])
	line = str(input()).split()
	for i in range(n):
		if line[i] == '0':
			num[i + 1][0] = 1 + min(num[i])
			num[i + 1][1] = MAX
			num[i + 1][2] = MAX
		elif line[i] == '1':
			num[i + 1][0] = 1 + min(num[i])
			num[i + 1][1] = min(num[i][0], num[i][2])
			num[i + 1][2] = MAX
		elif line[i] == '2':
			num[i + 1][0] = 1 + min(num[i])
			num[i + 1][1] = MAX
			num[i + 1][2] = min(num[i][0], num[i][1])
		elif line[i] == '3':
			num[i + 1][0] = 1 + min(num[i])
			num[i + 1][1] = min(num[i][0], num[i][2])
			num[i + 1][2] = min(num[i][0], num[i][1])
	print(min(num[n]))
__starting_point()


n = int(input())
al = list(map(int, input().split()))
(res, prev) = (0, 0)
for x in al:
	if x == 0 or x == prev:
		prev = 0
		res += 1
	elif x == 1 or x == 2:
		prev = x
	elif prev > 0 and x == 3:
		prev = 3 - prev
print(res)


a = int(input())
dn = list(map(int, input().split(' ')))
c = 0
pr = 0
sp = 0
for e in range(a):
	if dn[e] == 0:
		c += 1
		pr = 0
		sp = 0
	elif dn[e] == 1:
		if pr == 0:
			pr = 1
			sp = 0
		elif pr == 1:
			c += 1
			pr = 0
			sp = 0
	elif dn[e] == 2:
		if sp == 0:
			sp = 1
			pr = 0
		elif sp == 1:
			c += 1
			sp = 0
			pr = 0
	elif dn[e] == 3:
		if pr == 1:
			pr = 0
			sp = 1
		elif sp == 1:
			sp = 0
			pr = 1
print(c)


numday = input()
dayorder = input()
array = map(int, dayorder.split(' '))
sumrest = 0
prev = 3
for i in array:
	if i == prev and prev != 3:
		i = 0
	elif i == 3 and prev != 3:
		i -= prev
	if i == 0:
		sumrest += 1
	prev = i
print(sumrest)


def main():
	n = int(input())
	dp_arr = [0, 0, 0]
	days = [int(day) for day in input().split()]
	for day in days:
		gym = dp_arr[0] + 1
		contest = dp_arr[1] + 1
		if day == 2 or day == 3:
			gym = min(dp_arr[1], dp_arr[2])
		if day == 1 or day == 3:
			contest = min(dp_arr[0], dp_arr[2])
		rest = 1 + min(dp_arr)
		dp_arr = [gym, contest, rest]
	print(min(dp_arr))
main()


n = int(input())
k = input().split()
ans = 0
for i in range(0, len(k)):
	if k[i] == '0':
		ans += 1
	elif i != 0:
		if k[i] == '3' and k[i - 1] == '2':
			k[i] = '1'
		elif k[i] == '3' and k[i - 1] == '1':
			k[i] = '2'
		elif k[i] == '2' and k[i - 1] == '2':
			ans += 1
			k[i] = '0'
		elif k[i] == '1' and k[i - 1] == '1':
			ans += 1
			k[i] = '0'
print(ans)


input()
mat = [0, 0, 0]
for i in map(int, input().split()):
	tmp = mat[:]
	mat[0] = min(tmp) + 1
	mat[1] = min(tmp[0], tmp[2]) if i == 1 or i == 3 else 10000000.0
	mat[2] = min(tmp[0], tmp[1]) if i == 2 or i == 3 else 10000000.0
print(min(mat))


n = int(input())
days = input().split(' ')
days = [int(x) for x in days]
ans = 0
state = None
for x in days:
	if x == 3:
		if state == None:
			continue
		else:
			state = 3 - state
	elif x == 2:
		if state == 2:
			ans += 1
			state = None
		else:
			state = 2
	elif x == 1:
		if state == 1:
			ans += 1
			state = None
		else:
			state = 1
	else:
		ans += 1
		state = None
print(ans)


day = int(input())
situations = input().split(' ')
dp = [[float('inf') for _ in range(3)] for _ in range(day + 1)]
for j in range(3):
	dp[0][j] = 0
for i in range(1, day + 1):
	dp[i][0] = 1 + min(dp[i - 1][0], dp[i - 1][1], dp[i - 1][2])
	if situations[i - 1] != '0' and situations[i - 1] != '1':
		dp[i][1] = min(dp[i - 1][0], dp[i - 1][2])
	if situations[i - 1] != '0' and situations[i - 1] != '2':
		dp[i][2] = min(dp[i - 1][0], dp[i - 1][1])
print(min(dp[day][0], dp[day][1], dp[day][2]))


n = int(input())
a = list(map(int, input().split()))
inf = 10 ** 10
dp = [0, 0]
for x in a:
	z = min(dp)
	if x == 0:
		dp[0] = 1 + z
		dp[1] = 1 + z
	elif x == 1:
		dp[1] = min(dp[0], dp[1] + 1)
		dp[0] = z + 1
	elif x == 2:
		dp[0] = min(dp[1], dp[0] + 1)
		dp[1] = z + 1
	else:
		(dp[0], dp[1]) = (min(dp[1], dp[0] + 1), min(dp[0], dp[1] + 1))
print(min(dp))


n = int(input())
a = [int(i) for i in input().split()]
action = 0
rest = 0
for i in range(n):
	if a[i] == 0:
		rest += 1
		action = 0
	elif a[i] == 1:
		if action != 1:
			action = 1
		else:
			rest += 1
			action = 0
	elif a[i] == 2:
		if action != 2:
			action = 2
		else:
			rest += 1
			action = 0
	elif action == 1:
		action = 2
	elif action == 2:
		action = 1
	else:
		j = i + 1
		while j < n and a[j] == 3:
			j += 1
		if j != n:
			if (j - i) % 2 + a[j] == 2:
				action = 2
			else:
				action = 1
print(rest)


n = int(input().strip())
a = list(map(int, input().split()))
d = [[0 for _ in range(3)] for _ in range(n)]
d[0][0] = 1
d[0][1] = 0 if a[0] in [1, 3] else 1
d[0][2] = 0 if a[0] in [2, 3] else 1
for i in range(1, n):
	d[i][0] = min(d[i - 1]) + 1
	if a[i] in [1, 3]:
		d[i][1] = min(d[i - 1][0], d[i - 1][2])
	else:
		d[i][1] = 1000
	if a[i] in [2, 3]:
		d[i][2] = min(d[i - 1][0], d[i - 1][1])
	else:
		d[i][2] = 1000
print(min(d[n - 1]))