#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 333;
const long long linf = 1e18 + inf;
const int N = 1e5 + 5;
int n, m;
char s[N];
long long dp[N][2][2][2];
long long f(int x, int l1, int l2, int l3) {
  if (x > n) {
    return l2 == n - 1;
  }
  if (l1 < x - 3 or l2 < x - 2 or l3 < x - 2) return 0;
  long long &r = dp[x][l1 & 1][l2 & 1][l3 & 1];
  if (r != -1) {
    return r;
  }
  r = 0;
  for (int i = 1; i <= m; i++) {
    int newL1 = (i == s[x - 1] ? l1 + 1 : l2);
    int newL2 = (i == s[x] ? l2 + 1 : max(newL1, l3));
    int newL3 = (i == s[x + 1] ? l3 + 1 : newL2);
    r += f(x + 1, newL1, newL2, newL3);
  }
  return r;
}
int main() {
  scanf("%d %d", &n, &m);
  scanf("%s", s + 1);
  for (int i = 1; i <= n; i++) {
    s[i] = s[i] - 'a' + 1;
  }
  memset(dp, -1, sizeof(dp));
  printf("%lld\n", f(1, 0, 0, 0));
  return 0;
}
