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