#include <bits/stdc++.h>
using namespace std;
const int maxn = 400000;
long long ans = 0;
int n, m;
char str[maxn];
int main() {
  scanf("%d %d", &n, &m);
  scanf("%s", str + 1);
  for (int i = 1; i <= n; i++) {
    int tmp = i;
    while (tmp <= n && str[tmp] == str[i]) ++tmp;
    --tmp;
    ans += 1LL * n * (m - 1);
    i = tmp;
  }
  int now = 1;
  for (int i = 2; i <= n; i++)
    if (str[i] == str[i - 1]) {
      ans -= 1LL * now * (now - 1) / 2;
      now = 1;
    } else if (now == 1)
      ++now;
    else {
      if (str[i] == str[i - 2])
        ++now;
      else {
        ans -= 1LL * now * (now - 1) / 2;
        now = 2;
      }
    }
  ans -= 1LL * now * (now - 1) / 2;
  printf("%I64d\n", ans);
  return 0;
}
