#include <bits/stdc++.h>
using namespace std;
int n, m;
long long f(const string& s) {
  long long res = 0;
  for (int i = 0; i + 1 < s.size(); ++i) {
    if (s[i] != s[i + 1]) {
      res += (m - 1) * (n - i - 1);
    }
  }
  return res;
}
long long g(const string& s) {
  long long res = 0;
  for (int i = 0; i + 1 < s.size(); ++i)
    if (s[i] != s[i + 1]) {
      int j = i + 1;
      while (j + 1 < s.size() && s[j + 1] == s[j - 1]) ++j;
      long long l = j - i + 1;
      res += l * (l - 1) / 2;
      i = j - 1;
    }
  return res;
}
int main() {
  string s;
  cin >> n >> m >> s;
  long long res = n * (m - 1) + f(s);
  reverse(s.begin(), s.end());
  res += f(s) - g(s);
  cout << res << endl;
  return 0;
}
