#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    int m, n;
    cin >> m >> n;
    if (m == 2) {
        int x = 0;
        for (int i = 0; i < n; i++) {
            int a;
            cin >> a;
            if ((i % 2 == 0) == (a == 1))x++;
        }
        cout << min(x, n - x) << endl;
    } else {
        vector<vector<int>> dp(n, vector<int>(2, 1145141919));
        dp[0][false] = 0, dp[0][true] = 1; // その日変えたか？
        int prev;
        cin >> prev;
        for (int i = 1; i < n; i++) {
            int now;
            cin >> now;

            dp[i][false] = dp[i - 1][true];
            if (prev != now) dp[i][false] = min(dp[i][false], dp[i - 1][false]);
            dp[i][true] = min(dp[i - 1][false], dp[i - 1][true]) + 1;

            prev = now;
        }
        cout << min(dp[n - 1][false], dp[n - 1][true]) << endl;
    }
    return 0;
}

