#include <bits/stdc++.h>
using namespace std;
int main() {
  int H, W;
  cin >> H >> W;
  char map[50][50] = {{0}};
  for (int count = 0; count < H; ++count) {
    cin >> map[count];
  }
  char result[52][52] = {{0}};
  for (int x = 0; x < H; ++x) {
    for (int y = 0; y < W; ++y) {
      if (map[x][y] == '#') {
        result[x][y] += 1;
        result[x][y + 1] += 1;
        result[x][y + 2] += 1;
        result[x + 1][y] += 1;
        result[x + 1][y + 1] = 10;
        result[x + 1][y + 2] += 1;
        result[x + 2][y] += 1;
        result[x + 2][y + 1] += 1;
        result[x + 2][y + 2] += 1;
      }
    }
  }
  for (int x = 1; x <= H; ++x) {
    for (int y = 1; y <= W; ++y) {
      if (result[x][y] < 10) {
        map[x - 1][y - 1] = result[x][y] + '0';
      }
    }
    cout << map[x - 1] << endl;
  }
}
