#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while ('0' > ch || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9') {
    x = (x << 1) + (x << 3) + ch - '0';
    ch = getchar();
  }
  return x * f;
}
long long n, m, ans, k = 1;
char a[100004];
int main() {
  scanf("%lld%lld", &n, &m);
  scanf("%s", a + 1);
  ans = n * (m - 1);
  for (int i = 2; i <= n; i++)
    if (a[i] != a[i - 1]) ans += n * (m - 1);
  for (int i = 2; i <= n; i++) {
    if (k == 1) {
      if (a[i] != a[i - 1]) ++k;
    } else {
      if (a[i] == a[i - 2])
        ++k;
      else {
        ans -= (k - 1) * k / 2;
        k = 1;
        if (a[i] != a[i - 1]) ++k;
      }
    }
  }
  ans -= (k - 1) * k / 2;
  printf("%lld", ans);
  return 0;
}
