#include <bits/stdc++.h>
using namespace std;
int n, c, d, k;
string s;
int main() {
  cin >> n >> k;
  cin >> s;
  if (k == 2) {
    for (int i = 0; i < n; i++) {
      if (s[i] - 'A' != i % 2)
        c++;
      else
        d++;
    }
    cout << min(c, d) << endl;
    if (c < d) {
      for (int i = 0; i < n; i++) {
        cout << char('A' + i % 2);
      }
    } else {
      for (int i = 0; i < n; i++) {
        cout << char('A' + 1 - (i % 2));
      }
    }
  } else {
    for (int i = 1; i < n; i++) {
      if (s[i] == s[i - 1]) {
        c++;
        s[i] = 'A';
        while (s[i] == s[i - 1] || s[i] == s[i + 1]) {
          s[i]++;
        }
      }
    }
    cout << c << endl << s;
  }
  return 0;
}
