#include <bits/stdc++.h>
using namespace std;
const int MAXN = 6 * 1e5;
const int INF = 1e9 + 7;
int n, k, f[MAXN][50];
string s;
int L[500], R[500];
int i;
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> k;
  cin >> s;
  s = "+" + s;
  for (i = 1; i <= n; i++) {
    L[0] = INF;
    L[1] = f[i - 1][1];
    for (int j = 2; j <= k; j++) L[j] = min(L[j - 1], f[i - 1][j]);
    R[k + 1] = INF;
    R[k] = f[i - 1][k];
    for (int j = k - 1; j >= 1; j--) R[j] = min(R[j + 1], f[i - 1][j]);
    for (int j = 1; j <= k; j++) {
      int add = 0;
      if (s[i] - 'A' + 1 != j) add = 1;
      f[i][j] = min(L[j - 1], R[j + 1]) + add;
    }
  }
  int ans = INF;
  for (int i = 1; i <= k; i++) ans = min(ans, f[n][i]);
  cout << ans << endl;
  int x;
  for (x = 1; x <= 26; x++)
    if (f[n][x] == ans) break;
  char ch;
  char res[MAXN];
  while (n) {
    ch = 'A' + x - 1;
    res[n] = ch;
    int add = 0;
    if (ch != s[n]) add = 1;
    int y;
    for (y = 1; y <= 26; y++)
      if (y != x && f[n - 1][y] + add == f[n][x]) {
        x = y;
        break;
      }
    n--;
  }
  for (int i = 1; i <= s.length() - 1; i++) cout << res[i];
  return 0;
}
