#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:100000000")
using namespace std;
char s[100100];
int l[100100], f[100100];
int main() {
  int i, n, p;
  long long a = 0;
  scanf("%d%d%s", &n, &p, s);
  for (i = n - 1; i >= 0; i--) {
    f[i] = f[i + 1] + (s[i] != s[i + 1]);
    l[i] = 1;
    if (s[i] == s[i + 2]) l[i] += l[i + 2];
    if (i == n - 1 || s[i] == s[i + 1])
      a += (p - 1) * f[i];
    else
      a += (p - 2) * f[i] + (long long)(n - i - 2) * (p - 1) + p + f[i + 2] -
           min(2 * l[i], 2 * l[i + 1] + 1) + 2 - (s[i + 1] == s[i + 2]);
  }
  printf("%lld\n", a);
  return 0;
}
