// C++ implementation of the approach
#include <bits/stdc++.h>
using namespace std;
// Function to return the minimum
// inversions required so that no
// two adjacent elements are same
int min_changes(int a[], int n)
{
// To store the inversions required
// to make the array {1, 0, 1, 0, 1, 0, 1, ...}
// and {0, 1, 0, 1, 0, 1, 0, ...} respectively
int ans_a = 0, ans_b = 0;
// Find all the changes required
for (int i = 0; i < n; i++) {
if (i % 2 == 0) {
if (a[i] == 0)
ans_a++;
else
ans_b++;
}
else {
if (a[i] == 0)
ans_b++;
else
ans_a++;
}
}
// Return the required answer
return min(ans_a, ans_b);
}
// Driver code
int main()
{
int a[] = { 1, 0, 0, 1, 0, 0, 1, 0 };
int n = sizeof(a) / sizeof(a[0]);
cout << min_changes(a, n);
return 0;
}