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