/*
ID: yc7831
PROG: concom
LAnG: C++
*/
#include <iostream>
#include <fstream>
#include <cstring>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
int n;
int f[30001][4];
int s[30001];
int ans=1000000;
int i,j,k;
int main()
{
ifstream in("egroup.in");
ofstream out("egroup.out");
in >> n;
for (i=1;i<=n;i++)
in >> s[i];
for (j=1;j<=3;j++)
{
for (i=1;i<=n;i++)
{
f[i][j]=1000000;
for (k=1;k<=j;k++)
{
if (f[i-1][k]<f[i][j])
f[i][j]=f[i-1][k];
}
if (s[i]!=j)
f[i][j]++;
}
if (f[n][j]<ans)
ans=f[n][j];
}
for (j=3;j>=1;j--)
{
for (i=1;i<=n;i++)
{
f[i][j]=1000000;
for (k=j;k<=3;k++)
{
if (f[i-1][k]<f[i][j])
f[i][j]=f[i-1][k];
}
if (s[i]!=j)
f[i][j]++;
}
if (f[n][j]<ans)
ans=f[n][j];
}
out<<ans;
return 0;
}