#include <bits/stdc++.h>
using namespace std;
const int inf = (1 << 28);
int n, m, dp[550][26][26], cost[550][26][26], num[26][2];
int from[550][26][26][2], ans[550][2];
char mp[550][550];
struct Node {
  int j, k, v;
  Node() {}
  Node(int j, int k, int v) : j(j), k(k), v(v) {}
  bool operator<(const Node &node) const { return v > node.v; }
};
priority_queue<Node> q;
vector<Node> v;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%s", mp[i]);
  if (m == 1) {
    int ans = 0;
    for (int i = 1; i < n; i++) {
      if (mp[i][0] == mp[i - 1][0]) {
        ans++;
        for (int j = 0; j < 26; j++)
          if (j + 'a' != mp[i][0] && (i == n - 1 || j + 'a' != mp[i + 1][0])) {
            mp[i][0] = j + 'a';
            break;
          }
      }
    }
    printf("%d\n", ans);
    for (int i = 0; i < n; i++) printf("%s\n", mp[i]);
    return 0;
  }
  for (int i = 0; i < n; i++) {
    memset(num, 0, sizeof(num));
    for (int j = 0; j < m; j++) num[mp[i][j] - 'a'][j & 1]++;
    for (int j = 0; j < 26; j++)
      for (int k = 0; k < 26; k++) cost[i][j][k] = m - num[j][0] - num[k][1];
  }
  for (int i = 0; i < 26; i++)
    for (int j = 0; j < 26; j++) {
      if (i == j)
        dp[0][i][j] = inf;
      else
        dp[0][i][j] = cost[0][i][j];
    }
  for (int i = 1; i < n; i++) {
    while (!q.empty()) q.pop();
    for (int j = 0; j < 26; j++)
      for (int k = 0; k < 26; k++) {
        q.push(Node(j, k, dp[i - 1][j][k]));
      }
    for (int j = 0; j < 26; j++)
      for (int k = 0; k < 26; k++) {
        if (j == k)
          dp[i][j][k] = inf;
        else {
          while (q.top().j == j || q.top().k == k) {
            v.push_back(q.top());
            q.pop();
          }
          dp[i][j][k] = cost[i][j][k] + dp[i - 1][q.top().j][q.top().k];
          from[i][j][k][0] = q.top().j;
          from[i][j][k][1] = q.top().k;
          for (vector<Node>::iterator it = v.begin(); it != v.end(); it++) {
            q.push(*it);
          }
          v.clear();
        }
      }
  }
  int jj = -1, kk;
  for (int j = 0; j < 26; j++)
    for (int k = 0; k < 26; k++) {
      if (jj == -1 || dp[n - 1][j][k] < dp[n - 1][jj][kk]) {
        jj = j;
        kk = k;
      }
    }
  printf("%d\n", dp[n - 1][jj][kk]);
  ans[n - 1][0] = jj;
  ans[n - 1][1] = kk;
  for (int i = n - 1; i > 0; i--) {
    ans[i - 1][0] = from[i][jj][kk][0];
    ans[i - 1][1] = from[i][jj][kk][1];
    jj = ans[i - 1][0];
    kk = ans[i - 1][1];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) printf("%c", ans[i][j & 1] + 'a');
    printf("\n");
  }
  return 0;
}
