#include <bits/stdc++.h>
using namespace std;
long long n, m, g[500005], sum;
string second;
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m >> second;
  second = "$" + second;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    if (second[i] != second[i - 1]) {
      ans += n * m - n;
    }
  }
  long long cur = 1;
  for (int i = 2; i <= n; i++) {
    if (cur == 1) {
      if (second[i] == second[i - 1]) continue;
      if (second[i] != second[i - 1]) {
        cur = 2;
      }
    } else {
      if (second[i] == second[i - 2]) {
        cur++;
        continue;
      } else {
        ans -= cur * (cur - 1) / 2;
        if (second[i] == second[i - 1]) {
          cur = 1;
        } else {
          cur = 2;
        }
      }
    }
  }
  ans -= cur * (cur - 1) / 2;
  cout << ans << '\n';
  return 0;
}
