#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
long long n, m, k, cc;
string s;
int main() {
  k = 1;
  cc = 0;
  cin >> n >> m >> s;
  for (int i = 1; i < (int)n; i++) {
    if (s[i] != s[i - 1]) k++;
  }
  for (int i = 0; i < (int)n - 1; i++) {
    if (s[i] != s[i + 1]) {
      long long j = i;
      for (; i + 2 < n; i++) {
        if (s[i + 2] != s[i]) break;
      }
      j = (i - j + 2);
      cc += j * (j - 1) / 2;
    }
  }
  cout << k * (m * n - n) - cc << endl;
  return 0;
}
