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