#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int M = 2e6 + 5;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const double eps = 1e-4;
int n, m;
char s[N];
int main() {
  scanf("%d%d", &n, &m);
  scanf("%s", s + 1);
  long long ans = 0;
  for (int i = 1; i <= n; i++)
    if (i == 1 || s[i] != s[i - 1]) ans += n * m - n;
  long long k = 1;
  for (int i = 2; i <= n; i++) {
    if (k == 1 && s[i] != s[i - 1])
      k++;
    else if (k > 1 && s[i] == s[i - 2])
      k++;
    else if (k > 1 && s[i] != s[i - 2]) {
      ans -= (k - 1) * k / 2;
      k = 1 + (s[i] != s[i - 1]);
    }
  }
  cout << ans - (k - 1) * k / 2 << endl;
  return 0;
}
