#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int H, W;
  cin >> H >> W;
  vector<string> S(H);
  for (size_t i = 0; i < H; i++) {
    cin >> S[i];
  }
  for (size_t i = 0; i < H; i++) {
    for (size_t j = 0; j < W; j++) {
      if (S[i][j] == '.') {
        int counter = 0;
        if (S[i - 1][j] == '#' && (i - 1) >= 0) {
          counter++;
        }
        if (S[i - 1][j - 1] == '#' && (i - 1) >= 0 && (j - 1) >= 0) {
          counter++;
        }
        if (S[i - 1][j + 1] == '#' && (i - 1) >= 0 && (j + 1) < S[i].length()) {
          counter++;
        }
        if (S[i][j + 1] == '#' && (j + 1) < S[i].length()) {
          counter++;
        }
        if (S[i][j - 1] == '#' && (j - 1) >= 0) {
          counter++;
        }
        if (S[i + 1][j - 1] == '#' && (i + 1) < H && (j - 1) >= 0) {
          counter++;
        }
        if (S[i + 1][j] == '#' && (i + 1) < H) {
          counter++;
        }
        if (S[i + 1][j + 1] == '#' && (i + 1) < H && (j + 1) < S[i].length()) {
          counter++;
        }
        string sc = to_string(counter);
        S[i][j] = sc[0];
      }
    }
  }
  for (size_t i = 0; i < H; i++) {
    cout << S[i] << endl;
  }
  return 0;
}
