#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
const int mo = 1000000007;
const int inf = (int)1e9;
const long long Inf = (long long)1e10;
inline int IN() {
  char ch;
  (ch = getchar());
  int f = 0, x = 0;
  for (; ((ch) == '\n' || (ch) == '\r' || (ch) == '\t' || (ch) == ' ');
       (ch = getchar()))
    ;
  if (ch == '-') f = 1, (ch = getchar());
  for (; !((ch) == '\n' || (ch) == '\r' || (ch) == '\t' || (ch) == ' ');
       (ch = getchar()))
    x = x * 10 + ch - '0';
  return (f) ? (-x) : (x);
}
int Pow(int x, int y, int p) {
  int A = 1;
  for (; y; y >>= 1, x = (long long)x * x % p)
    if (y & 1) A = (long long)A * x % p;
  return A;
}
int n, m;
long long f[N][10];
char s[N];
int main() {
  scanf("%d%d", &n, &m);
  scanf("%s", s + 1);
  for (int i = (int)1; i <= (int)n; i++) s[i] -= 'a';
  s[n + 1] = -1;
  for (int i = (int)0; i < (int)m; i++) {
    int stat = 1;
    if (i == s[1]) stat |= 2;
    if (i == s[2] || i == s[1]) stat |= 4;
    f[1][stat]++;
  }
  for (int i = (int)2; i <= (int)n + 1; i++) {
    for (int j = (int)0; j < (int)8; j++) {
      if (j == 7) j = 7;
      int stat[4] = {i - 3 + (j & 1), i - 2 + ((j & 2) > 0),
                     i - 2 + ((j & 4) > 0), 0};
      for (int k = (int)0; k < (int)m; k++) {
        int newstat[4] = {};
        for (int l = (int)1; l <= (int)3; l++) {
          if (k == s[i - 2 + l])
            newstat[l] = stat[l - 1] + 1;
          else
            newstat[l] = max(newstat[l - 1], stat[l]);
        }
        int New = (newstat[1] - i + 2) + (newstat[2] - i + 1) * 2 +
                  (newstat[3] - i + 1) * 4;
        if (newstat[1] >= i - 2 && newstat[2] >= i - 1 && newstat[3] >= i - 1)
          f[i][New] += f[i - 1][j];
      }
    }
  }
  cout << f[n][0] + f[n][1] << endl;
  return 0;
}
