#include <iostream>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll s[110000];
bool ok;
ll ans;
ll m, n;
int main() {
	cin >> m >> n;
	REP(i, n)cin >> s[i];
	if (m == 2) {
		ll a1 = 0, a2 = 0;
		REP(i, n) {
			if (i % 2 == 0 and s[i] == 1)a1++;
			if (i % 2 == 1 and s[i] == 2)a1++;
		}
		REP(i, n) {
			if (i % 2 == 0 and s[i] == 2)a2++;
			if (i % 2 == 1 and s[i] == 1)a2++;
		}
		cout << min(a1, a2) << endl;
		return 0;
	}
	REP(i, n - 1) {
		if (s[i] == s[i + 1]) {
			ans++;
			s[i + 1] = -1;
		}
	}
	cout << ans << endl;
}


