#include <bits/stdc++.h>
const int maxn = 1e5 + 1;
int n, m, l = 1;
long long a;
char s[maxn];
int main() {
  scanf("%d%d%s", &n, &m, s + 1);
  for (int i = 1; i <= n; i++)
    if (s[i] != s[i - 1]) a += n * (m - 1);
  for (int i = 2; i <= n; i++)
    if (l == 1 && s[i] != s[i - 1] || l > 1 && s[i] == s[i - 2])
      ++l;
    else if (a -= 1ll * l * (l - 1) >> 1)
      l = 1 + (s[i] != s[i - 1]);
  printf("%lld\n", a -= 1ll * l * (l - 1) >> 1);
  return 0;
}
