#include <bits/stdc++.h>
using namespace std;
int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy[] = {0, -1, 1, -1, 1, -1, 0, 1};
int main() {
  int h, w;
  cin >> h >> w;
  string s[100];
  for (int i = 0; i < (h); ++i) {
    cin >> s[i];
  }
  for (int i = 0; i < (h); ++i) {
    for (int j = 0; j < (w); ++j) {
      if (s[i][j] == '.') {
        int res = 0;
        for (int k = 0; k < (8); ++k) {
          int x = i + dx[k];
          int y = j + dx[k];
          if (0 <= x and x < h and 0 <= y and y < w and s[x][y] == '#') {
            res++;
          }
        }
        s[i][j] = '0' + res;
      }
    }
  }
  for (int i = 0; i < (h); ++i) {
    cout << s[i] << endl;
  }
  return 0;
}
