#include <bits/stdc++.h>
using namespace std;
int n, m;
string s;
long long F(long long l) { return l * (l + 1) / 2; }
int main() {
  cin >> n >> m >> s;
  long long R = 0;
  R += (m - 1) * n;
  for (int i = (int)(2); i < (int)(n + 1); ++i) R += 2 * (m - 1) * (n + 1 - i);
  for (int i = (int)(0); i < (int)(n - 1); ++i)
    if (s[i] == s[i + 1]) R -= (m - 1) * (n);
  char c1 = s[0], c2 = s[1];
  int len = 0;
  for (int i = (int)(1); i < (int)(n); ++i) {
    if (c1 == s[i - 1] && c2 == s[i]) {
      ++len;
      swap(c1, c2);
    } else {
      if (c1 != c2) R -= F(len);
      len = 1;
      c1 = s[i];
      c2 = s[i - 1];
    }
  }
  if (c1 != c2) R -= F(len);
  printf("%I64d\n", R);
  return 0;
}
