#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ii pair <int,int>
#define F first
#define S second
#define ever (;;)
bool p0,p1;
int n,ans;
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
int x;
scanf("%d",&x);
if( x )
p1 = 1;
else
p0 = 1;
if( p1 && p0 )
{
p1 = p0 = 0;
ans++;
}
}
printf("%d\n",ans);
}