#include <bits/stdc++.h>
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001
#define MAXN 1000005
#define ins insert
#define pb push_back
#define mp make_pair
#define sz size
#define rep(i, n) for(int i = 0; i < n; ++i)
#define sd(n) scanf("%d",&n)
#define sll(n) scanf("%I64d",&n)
#define pdn(n) printf("%d\n",n)
#define plln(n) printf("%I64d\n",n)
#define pd(n) printf("%d ",n)
#define nl() printf("\n")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int, int> pii;
int n, k; string s;
int dp[500005][27];
int solve(int idx, char prev) {
if(idx == 0) {
if(prev == s[idx])
return dp[idx][prev-'A'] = 1;
return dp[idx][prev-'A'] = 0;
}
if(dp[idx][prev-'A'] != -1)
return dp[idx][prev-'A'];
if(prev == s[idx]) {
int ans = INF;
rep(i, k) {
if(i+'A' != prev)
ans = min(ans, 1+solve(idx-1, i+'A'));
}
return dp[idx][prev-'A'] = ans;
}
else {
int ans = solve(idx-1, s[idx]);
rep(i, k) {
if(i+'A' != prev)
ans = min(ans, 1+solve(idx-1, i+'A'));
}
return dp[idx][prev-'A'] = ans;
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
rep(i, 500005) {
rep(j, 27) {
dp[i][j] = -1;
}
}
cin >> n >> k >> s;
cout << solve(n-1, '[') << endl;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CgojZGVmaW5lIElORiAxMDAwMDAwMDAwCiNkZWZpbmUgTU9EIDEwMDAwMDAwMDcKI2RlZmluZSBFUFMgMC4wMDAwMDAwMQojZGVmaW5lIE1BWE4gMTAwMDAwNQojZGVmaW5lIGlucyBpbnNlcnQKI2RlZmluZSBwYiBwdXNoX2JhY2sKI2RlZmluZSBtcCBtYWtlX3BhaXIKI2RlZmluZSBzeiBzaXplCiNkZWZpbmUgcmVwKGksIG4pIGZvcihpbnQgaSA9IDA7IGkgPCBuOyArK2kpCiNkZWZpbmUgc2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