#include <bits/stdc++.h>
using namespace std;
char s[100010];
int main() {
  long long n, m, g = 1, i, j;
  scanf("%lld", &n);
  scanf("%lld", &m);
  scanf("%s", &s);
  for (i = 1; i < n; ++i)
    if (s[i] != s[i - 1]) g++;
  long long ans = g * n * (m - 1);
  long long cnt = 0;
  for (i = 0; i < n - 1; ++i) {
    if (s[i] != s[i + 1]) {
      bool f = 0;
      for (j = i + 2; j < n; ++j) {
        if (s[j] == s[i + f]) {
          f = 1 - f;
        } else
          break;
      }
      j = j - i;
      cnt = cnt + j * (j - 1) / 2;
      i = i + j - 2;
    }
  }
  printf("%lld\n", ans - cnt);
}
