#include <bits/stdc++.h>
using namespace std;
const int MOD = 51123987;
const double PI = 3.141592653528;
const int INF = 1000000000;
char a[510][510];
char aa[510][510];
int v[510][27][27];
pair<int, pair<int, int> > dp[510][27][27];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) cin >> a[i][j];
  if (m == 1) {
    int ans = 0;
    string s;
    s += a[1][1];
    for (int i = 2; i <= n; ++i) {
      if (a[i][1] == s.back()) {
        if (s.back() != 'a' && a[i + 1][1] != 'a')
          s.push_back('a');
        else if (s.back() != 'b' && a[i + 1][1] != 'b')
          s.push_back('b');
        else
          s.push_back('c');
        ++ans;
      } else
        s += a[i][1];
    }
    cout << ans << "\n";
    for (int i = 1; i <= n; ++i, cout << endl) cout << s[i - 1];
    return 0;
  }
  for (int k = 1; k <= n; ++k) {
    for (int j = 0; j < 26; ++j) {
      for (int l = 0; l < 26; ++l) {
        if (j == l) continue;
        int& t = v[k][j][l];
        for (int p = 1; p <= m; ++p)
          if (a[k][p] != 'a' + ((p & 1) ? j : l)) ++t;
      }
    }
  }
  for (int i = 1; i <= n; ++i)
    for (int j = 0; j < 26; ++j)
      for (int k = 0; k < 26; ++k) dp[i][j][k].first = 10000000;
  for (int i = 0; i < 26; ++i)
    for (int j = 0; j < 26; ++j) dp[0][i][j].first = ((i == j) ? 1000000 : 0);
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < 26; ++j) {
      for (int k = 0; k < 26; ++k) {
        for (int t = 0; t < 26; ++t) {
          if (j == t) continue;
          for (int s = 0; s < t; ++s) {
            if (k == s) continue;
            if (dp[i][j][k].first > dp[i - 1][t][s].first + v[i][j][k])
              dp[i][j][k].first = dp[i - 1][t][s].first + v[i][j][k],
              dp[i][j][k].second.first = t, dp[i][j][k].second.second = s;
          }
        }
        for (int t = 0; t < 26; ++t) {
          if (j == t) continue;
          for (int s = t + 1; s < 26; ++s) {
            if (k == s) continue;
            if (dp[i][j][k].first > dp[i - 1][t][s].first + v[i][j][k])
              dp[i][j][k].first = dp[i - 1][t][s].first + v[i][j][k],
              dp[i][j][k].second.first = t, dp[i][j][k].second.second = s;
          }
        }
      }
    }
  }
  int l1 = 0, l2 = 1;
  for (int i = 0; i < 26; ++i) {
    for (int j = 0; j < 26; ++j) {
      if (i == j) continue;
      if (dp[n][i][j].first < dp[n][l1][l2].first) l1 = i, l2 = j;
    }
  }
  cout << dp[n][l1][l2].first << "\n";
  for (int i = 1; i <= m; ++i) aa[n][i] = 'a' + ((i & 1) ? l1 : l2);
  for (int j = n - 1; j >= 1; --j) {
    int ll1 = l1, ll2 = l2;
    l1 = dp[j + 1][ll1][ll2].second.first;
    l2 = dp[j + 1][ll1][ll2].second.second;
    for (int i = 1; i <= m; ++i) aa[j][i] = 'a' + ((i & 1) ? l1 : l2);
  }
  for (int i = 1; i <= n; ++i, cout << endl)
    for (int j = 1; j <= m; ++j) cout << aa[i][j];
  return 0;
}
