#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
const int INF = 0x3f3f3f3f;
int n, m;
string s;
long long ans;
int k = 1;
int main() {
  scanf("%d %d", &n, &m);
  cin >> s;
  int len = s.size();
  for (int i = 1; i < len; ++i) {
    k += (s[i] != s[i - 1]);
  }
  ans = 1ll * (n * m - n) * k;
  for (int i = 0; i < len - 1;) {
    if (s[i] == s[i + 1]) {
      ++i;
      continue;
    }
    int tmp = 2;
    while (i + tmp < len and s[i + tmp] == s[i + tmp % 2]) {
      tmp++;
    }
    ans -= 1ll * tmp * (tmp - 1) / 2;
    i = i + tmp - 1;
  }
  printf("%lld\n", ans);
  return 0;
}
