#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 7;
int i, j, l, t, n, m;
long long ans, k;
char s[MAXN];
int main() {
  cin >> n >> m;
  cin >> s + 1;
  ans = n * (m - 1);
  for (int i = 2; i <= n; i++)
    if (s[i] != s[i - 1]) ans += n * (m - 1);
  k = 1;
  for (int i = 2; i <= n; i++) {
    if (k == 1) {
      if (s[i] != s[i - 1])
        k++;
      else
        continue;
    } else {
      if (s[i] == s[i - 2])
        k++;
      else {
        ans -= (k - 1) * k / 2;
        k = 1;
        if (s[i] != s[i - 1]) k = 2;
      }
    }
  }
  ans -= (k - 1) * k / 2;
  cout << ans << endl;
  return 0;
}
