#include <bits/stdc++.h>
using namespace std;
char s[1000010];
int main() {
  int n, m;
  cin >> n >> m;
  cin >> s;
  long long sum = 0;
  int k = 0;
  for (int i = 0; i < n; i++) {
    while (s[i] == s[i + 1]) i++;
    k++;
  }
  sum += (long long)k * n * (m - 1);
  for (int i = 0; i < n - 1; i++) {
    if (s[i] == s[i + 1]) continue;
    int p = i, q = i + 1;
    while (p + 2 < n && s[p] == s[p + 2]) {
      q = p + 2;
      p++;
    }
    int w = q - i + 1;
    sum -= (long long)w * (w - 1) / 2;
    i = q - 1;
  }
  cout << sum << endl;
}
