#include <bits/stdc++.h>
using namespace std;
int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> s(h, vector<char>(w));
  for (int n = 0; n < h; n++) {
    for (int m = 0; m < w; m++) {
      if (s[n][m] == '.') {
        for (int i = -1; i <= 1; i++) {
          int cnt = 0;
          for (int j = -1; j <= 1; j++) {
            if (s[n + i][m + j] == '#') cnt++;
            s[n][m] = cnt;
          }
        }
      }
    }
  }
  for (int i = 0; i < (int)(h); i++) {
    for (int j = 0; j < (int)(w); j++) {
      cout << s[i][j];
    }
    cout << endl;
  }
}
