#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

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

	if (m == 2) {
		// 1,2,1,2,....
		int cnt1 = 0;
		for (int i = 0; i < n; ++i) {
			if ((i & 1) && a[i] == 1) ++cnt1;
			if (!(i & 1) && a[i] == 2) ++cnt1;
		}
		// 2,1,2,1,....
		int cnt2 = 0;
		for (int i = 0; i < n; ++i) {
			if ((i & 1) && a[i] == 2) ++cnt2;
			if (!(i & 1) && a[i] == 1) ++cnt2;
		}
		// 出力
		cout << min(cnt1, cnt2) << endl;
	}
	else {
		// 前日と同じものが出てきたら変更
		int res = 0;
		for (int i = 1; i < n; ++i)
			if (a[i - 1] == a[i])
				++res, ++i;
		cout << res << endl;
	}

	return 0;
}
