#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
const int inf = 2147483647;
long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') x = x * 10ll + ch - '0', ch = getchar();
  return x * f;
}
long long n, m, ans = 0;
char s[N];
int main() {
  n = read(), m = read();
  scanf("%s", s + 1);
  ans = n * (m - 1);
  for (int i = 2; i <= n; i++)
    if (s[i] != s[i - 1]) ans += n * (m - 1);
  long long l = 1;
  s[0] = '#';
  for (int i = 2; i <= n; i++) {
    if (l == 1) {
      if (s[i] != s[i - 1]) l++;
    } else {
      if (s[i] == s[i - 2])
        l++;
      else {
        ans -= (l - 1) * l / 2;
        l = 1 + (s[i] != s[i - 1]);
      }
    }
  }
  ans -= (l - 1) * l / 2;
  cout << ans;
}
