#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n, m;
string g[500 + 1];
int occ_odd[500 + 1][26] = {};
int occ_even[500 + 1][26] = {};
set<tuple<int, int, int>> optset[500 + 1];
int opt[500 + 1][26][26];
tuple<int, int, int> pre[500 + 1][26][26];
void relax(int i, int c1, int c2, int val, int pc1, int pc2) {
  if (opt[i][c1][c2] > val) {
    opt[i][c1][c2] = val;
    pre[i][c1][c2] = {i - 1, pc1, pc2};
  }
}
int cost(int i, int c1, int c2) {
  return (m + 1) / 2 - occ_even[i][c1] + m / 2 - occ_odd[i][c2];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> g[i];
    for (int j = 0; j < m; j++) {
      (j % 2 ? occ_odd : occ_even)[i][g[i][j] - 'a']++;
    }
  }
  for (int i = 0; i <= n; i++) {
    for (int c1 = 0; c1 < 26; c1++) {
      for (int c2 = 0; c2 < 26; c2++) {
        if (i == 0) {
          opt[i][c1][c2] = 0;
        } else if (c1 == c2) {
          opt[i][c1][c2] = (500 * 500);
        } else {
          opt[i][c1][c2] = (500 * 500);
          vector<tuple<int, int, int>> removed;
          while (get<1>(*optset[i - 1].begin()) == c1 or
                 get<2>(*optset[i - 1].begin()) == c2) {
            removed.push_back(*optset[i - 1].begin());
            optset[i - 1].erase(optset[i - 1].begin());
          }
          relax(i, c1, c2, get<0>(*optset[i - 1].begin()) + cost(i, c1, c2),
                get<1>(*optset[i - 1].begin()), get<2>(*optset[i - 1].begin()));
          for (auto t : removed) {
            optset[i - 1].insert(t);
          }
        }
      }
    }
    for (int c1 = 0; c1 < 26; c1++) {
      for (int c2 = 0; c2 < 26; c2++) {
        if (c1 != c2) {
          optset[i].insert({opt[i][c1][c2], c1, c2});
        }
      }
    }
  }
  int gc1 = 0, gc2 = 0;
  for (int c1 = 0; c1 < 26; c1++) {
    for (int c2 = 0; c2 < 26; c2++) {
      if (opt[n][c1][c2] < opt[n][gc1][gc2]) {
        gc1 = c1, gc2 = c2;
      }
    }
  }
  cout << opt[n][gc1][gc2] << '\n';
  for (int i = n; i >= 1; i--) {
    for (int j = 0; j < m; j++) {
      g[i][j] = (j % 2 ? gc2 : gc1) + 'a';
    }
    int ngc1 = get<1>(pre[i][gc1][gc2]);
    int ngc2 = get<2>(pre[i][gc1][gc2]);
    gc1 = ngc1, gc2 = ngc2;
  }
  for (int i = 1; i <= n; i++) {
    cout << g[i] << '\n';
  }
  return 0;
}
