#include <bits/stdc++.h>
using namespace std;
int main (){
#ifndef ONLINE_JUDGE
freopen("SuhaibSawalha1","r",stdin);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
bool ok = 0, ok2 = 0;
int ans = 0;
while (n--) {
int x;
cin >> x;
ok |= x == 0;
ok2 |= x == 1;
if (ok && ok2) {
++ans;
ok = ok2 = 0;
}
}
cout << ans;
return 0;
}