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