#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;

int main() {
    ll m, n, a[100010];
    cin >> m >> n;
    for (int i = 0; i < n; i++) cin >> a[i];

    if (m == 2) {
        ll tmp = 0;
        for (int i = 0; i < n; i++) tmp += (a[i] == i % 2 + 1);
        cout << min(tmp, n - tmp) << endl;
    }
    else {
        vector<int> v;
        int idx = 0;
        while (idx < n) {
            int sub = 0;
            while (idx + sub < n && a[idx] == a[idx + sub]) sub++;
            v.push_back(sub);
            idx += sub;
        }

        int ans = 0;
        for (int i = 0; i < v.size(); i++) {
            ans += v[i] / 2;
        }
        cout << ans << endl;
    }

}
