#include <bits/stdc++.h>
using namespace std;
int n, m;
char s[100100];
long long dp[100100][2][2][2];
long long dfs(int x, int l1, int l2, int l3) {
  if (x == n) return l2 == n - 1;
  if (l1 < x - 2 || l2 < x - 1 || l3 < x - 1) return 0;
  long long& res = dp[x][l1 & 1][l2 & 1][l3 & 1];
  if (res != -1) return res;
  res = 0;
  int nl1, nl2, nl3;
  for (int i = 0; i < m; ++i) {
    nl1 = (i == s[x] - 'a' ? l1 + 1 : l2);
    nl2 = (i == s[x + 1] - 'a' ? l2 + 1 : max(nl1, l3));
    nl3 = (i == s[x + 2] - 'a' ? l3 + 1 : nl2);
    res += dfs(x + 1, nl1, nl2, nl3);
  }
  return res;
}
int main() {
  scanf("%d%d", &n, &m);
  scanf("%s", s + 1);
  memset(dp, -1, sizeof(dp));
  printf("%lld\n", dfs(0, 0, 0, 0));
  return 0;
}
