#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    int M, N; cin >> M >> N;
    vector<int> A(N); for (auto &a : A) cin >> a;
    int ans = 0;
    if (M != 2) {
        for (int i = 0; i < N; i++) {
            int n = 1;
            while (i + 1 < N && A[i] == A[i + 1]) {
                i++, n++;
            }
            ans += n / 2;
        }
    } else {
        int a = 0;
        for (int i = 0; i < N; i++) a += A[i] == ((i % 2 == 0) + 1);
        int b = 0;
        for (int i = 0; i < N; i++) b += A[i] == ((i % 2 == 1) + 1);
        ans = min(a, b);
    }
    cout << ans << endl;
    return 0;
}

