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