#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
char s[N];
int main() {
  int n, m;
  scanf("%d%d%s", &n, &m, s);
  long long ans = n * (m - 1);
  for (int i = 1; i < n; i++)
    if (s[i] != s[i - 1]) ans += n * (m - 1);
  int cur = 1;
  for (int i = 1; i < n; i++) {
    if (cur == 1) {
      if (s[i] == s[i - 1])
        continue;
      else
        cur++;
    } else {
      if (s[i] == s[i - 2])
        cur++;
      else {
        ans -= 1LL * cur * (cur - 1) / 2;
        if (s[i] == s[i - 1])
          cur = 1;
        else
          cur = 2;
      }
    }
  }
  ans -= 1LL * cur * (cur - 1) / 2;
  printf("%lld\n", ans);
  return 0;
}
