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: competition

Starter code:

Solutions:
import sys

inp = sys.stdin
#inp = open('input.txt', 'r')

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))


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)


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))


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))



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)


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)

# print(solver([1, 3, 2, 0]))
# print(solver([1, 3, 3, 2, 1, 2, 3]))
# print(solver([2, 2]))

main()

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:  # 3
            a1 = 1 if a1 != 1 else 2
            a2 = 2 if a2 != 2 else 1
        else:  # 0
            a1 = a2 = 0
            z += 1
    print(x1 + z)


def __starting_point():
    main()

__starting_point()

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]))


"""
    This code is part of the codeforces problems solved in the repository[1]. 
    All solutions are written in python3.
    
    [1]: https://github.com/praveendath92/codeforces
"""

####### common base functions ########
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(' ')]

####### End of base functions ########


#=========== Start of main code ============
T = read_int()
D = read_int_array()

# Day one checking and init of actual tasks per day
AD = [-1]*len(D)
AD[0] = D[0]
rests = 1 if AD[0] == 0 else 0

# Check for the remaining days
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, 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())
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)


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'
    else:
        if days[i] != '3':
            last = days[i]
        else:
            if last == '1':
                last = '2'
            elif last == '2':
                last = '1'
            else:
                if i < n - 1:
                    if days[i+1] == '1':
                        last = '2'
                    elif days[i+1] == '2':
                        last = '1'
print(counter)


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()))


"""
    http://codeforces.com/problemset/problem/698/A

"""
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]
        # stdout.write(str(cur_act))
        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
        else:  # cur_act == 3
            if prev_act in (1, 2):
                prev_act = prev_act % 2 + 1
            else:
                if next_act in (1, 2):
                    prev_act = next_act % 2 + 1

        # rest_num += 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]))

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]]))


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


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
    else:
        if last == 1:
            last = 2
        elif last == 2:
            last = 1
print(rests)


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)

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)

# Name : Sachdev Hitesh
# College : GLSICA
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)

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):
    # print(xs)
    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

        else:
            if 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()


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(dp, contest(v), sport(v))
    
    print(n - max(dp))

__starting_point()

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()