#include <bits/stdc++.h>
using namespace std;
int n, m;
char A[200006];
int S[200006], T[200006];
void solve() {
  cin >> n >> m;
  scanf("%s", A + 1);
  long long re = 0;
  for (int i = (1), iend = (n); i <= iend; ++i) {
    S[i] = (A[i] != A[i + 1]) + S[i - 1];
    if (i >= 2 && A[i] == A[i - 2])
      T[i] = T[i - 1] + 1;
    else if (i >= 2)
      T[i] = 2;
    else
      T[i] = 1;
  }
  for (int r = (1), rend = (n); r <= rend; ++r) {
    if (A[r] != A[r - 1]) re += (m - 1) * 1ll * (r - 1);
    re += m - 1;
    re += S[r - 1] * 1ll * (m - 1);
    if (A[r] != A[r - 1]) re -= T[r] - 1;
  }
  cout << re << endl;
}
signed main() { solve(); }
