#include <bits/stdc++.h>
using namespace std;
char map[200][200];
int run[200][200] = {0};
int dir[8][2] = {{1, 0},  {1, 1},  {1, -1}, {0, 1},
                 {0, -1}, {-1, 1}, {-1, 0}, {-1, -1}};
void BFS(int i, int j) {
  int dx, dy, x;
  for (x = 0; x < 8; ++x) {
    dx = i + dir[x][0];
    dy = j + dir[x][1];
    if (map[dx][dy] != '#') {
      run[dx][dy]++;
    }
  }
}
int main() {
  int h, w, i, j;
  cin >> h >> w;
  for (i = 0; i < h; ++i) cin >> map[i];
  for (i = 0; i < h; ++i) {
    for (j = 0; j < w; ++j) {
      if (map[i][j] == '#') {
        BFS(i, j);
      }
    }
  }
  for (i = 0; i < h; ++i) {
    for (j = 0; j < w; ++j) {
      if (map[i][j] == '#')
        cout << '#';
      else
        cout << run[i][j];
    }
    cout << endl;
  }
}
