#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
char s[maxn];
int main() {
  int n, m;
  while (~scanf("%d %d", &n, &m)) {
    scanf("%s", s);
    long long cnt = 1;
    for (int i = 0; i < n; ++i) {
      if (i == 0 || s[i] == s[i - 1]) continue;
      cnt++;
    }
    long long ans = cnt * (n * m - n);
    cnt = 1;
    for (int i = 1; i < n; ++i) {
      if (cnt == 1) {
        if (s[i] != s[i - 1]) cnt++;
      } else {
        if (s[i] == s[i - 2]) {
          cnt++;
        } else {
          ans -= (cnt * (cnt - 1)) / 2;
          if (s[i] == s[i - 1])
            cnt = 1;
          else
            cnt = 2;
        }
      }
    }
    ans -= (cnt * (cnt - 1)) / 2;
    printf("%I64d\n", ans);
  }
  return 0;
}
