#include <bits/stdc++.h>
using namespace std;
int n, m;
char mm[600][600];
int num[600][26][4];
int col[600][4][4];
int val[600][4][4];
int dp[600][4][4];
int ca[600][4][4], cb[600][4][4];
int doit(int r, int c1, int c2) {
  if (r == n) return 0;
  int& res = dp[r][c1][c2];
  if (res != -1) return res;
  int i, j;
  res = -1000;
  int tmp;
  for (i = 0; i < 4; i++)
    for (j = 0; j < 4; j++) {
      if (col[r][0][i] == col[r][1][j]) continue;
      if (r > 0 && (col[r][0][i] == col[r - 1][0][c1] ||
                    col[r][1][j] == col[r - 1][1][c2]))
        continue;
      tmp = val[r][0][i] + val[r][1][j] + doit(r + 1, i, j);
      if (tmp > res) {
        res = tmp;
        ca[r][c1][c2] = i;
        cb[r][c1][c2] = j;
      }
    }
  return res;
}
void trace() {
  int r = 0, c1 = 0, c2 = 0;
  int i;
  while (r < n) {
    int nc1 = ca[r][c1][c2];
    int nc2 = cb[r][c1][c2];
    for (i = 0; i < m; i++) {
      if (i % 2 == 0)
        printf("%c", col[r][0][nc1] + 'a');
      else
        printf("%c", col[r][1][nc2] + 'a');
    }
    printf("\n");
    r++;
    c1 = nc1;
    c2 = nc2;
  }
}
int main() {
  scanf("%d %d", &n, &m);
  int i, j;
  for (i = 0; i < n; i++) scanf("%s", mm[i]);
  memset(num, 0, sizeof(num));
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      int id = mm[i][j] - 'a';
      num[i][id][j % 2]++;
    }
  }
  int a;
  for (i = 0; i < n; i++) {
    for (a = 0; a < 2; a++) {
      int b;
      for (b = 0; b < 4; b++) val[i][a][b] = -1;
      for (j = 0; j < 26; j++) {
        for (b = 0; b < 4; b++)
          if (num[i][j][a] > val[i][a][b]) break;
        int pos = b;
        if (pos == 4) continue;
        for (b = 3; b > pos; b--) {
          col[i][a][b] = col[i][a][b - 1];
          val[i][a][b] = val[i][a][b - 1];
        }
        col[i][a][b] = j;
        val[i][a][b] = num[i][j][a];
      }
    }
  }
  memset(dp, -1, sizeof(dp));
  int res = doit(0, 0, 0);
  printf("%d\n", n * m - res);
  trace();
}
