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