#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i = a; i < b; i++)

int main(){
    ll M, N; cin >> M >> N;
    vector<ll> A(N);
    rep(i, 0, N) cin >> A[i];

    int pre = -1, cnt = 1, ans = 0;
    if(M == 2){
        int cnt1 = 0, cnt2 = 0;
        rep(i, 0, N){
            if(A[i] != (i%2 + 1)) cnt1++;
            else cnt2++;
        }
        ans = min(cnt1, cnt2);
    }else{
        rep(i, 0, N){
            if(pre == A[i]) cnt++;
            else{
                pre = A[i];
                ans += cnt / 2;
                cnt = 1;
            }
        }
        ans += cnt / 2;
    }
    cout << ans << endl;
}
