#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
double rast(int x1, int y1, int x2, int y2) {
  return sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
}
int dp[500005][30];
int pre[500005][30];
int a[500005];
int main() {
  ios_base::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    char c;
    cin >> c;
    a[i] = (c - 'A');
  }
  for (int i = 0; i < k; i++) dp[0][i] = 1;
  dp[0][a[0]] = 0;
  int id1 = 0, c1 = a[0], id2 = 1, c2 = (a[0] + 1) % k;
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < k; j++) {
      if (j == c1) {
        dp[i][j] = id2 + (a[i] != j ? 1 : 0);
        pre[i][j] = c2;
      } else {
        dp[i][j] = id1 + (a[i] != j ? 1 : 0);
        pre[i][j] = c1;
      }
    }
    id1 = id2 = 2e9;
    for (int j = 0; j < k; j++) {
      if (dp[i][j] < id1) {
        id2 = id1;
        c2 = c1;
        id1 = dp[i][j];
        c1 = j;
      } else if (dp[i][j] < id2) {
        id2 = dp[i][j];
        c2 = j;
      }
    }
  }
  int ans = 2e9, pos;
  for (int i = 0; i < k; i++) {
    if (dp[n - 1][i] < ans) {
      ans = dp[n - 1][i];
      pos = i;
    }
  }
  cout << ans << '\n';
  string t;
  for (int i = n - 1; i >= 0; i--) {
    t += pos + 'A';
    pos = pre[i][pos];
  }
  reverse(t.begin(), t.end());
  cout << t;
}
