#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1, c = getchar();
  while (c < 48) c == '-' && (f = -1), c = getchar();
  while (c > 47) x = x * 10 + c - '0', c = getchar();
  return x * f;
}
const int MAXN = 100005;
char s[MAXN];
long long n, m, res;
int main(int argc, char const *argv[]) {
  n = read();
  m = read() - 1;
  scanf("%s", s + 1);
  for (int i = 2, p = 0; i <= n; res += i - p, ++i)
    if (s[i] == s[i - 1])
      res += n * m, p = i;
    else if (i ^ 1 && s[i] ^ s[i - 2])
      p = i - 1;
  printf("%lld\n", n * n * m - res);
  return 0;
}
