#include <bits/stdc++.h>
using namespace std;
int main() {
  int H, W;
  cin >> H >> W;
  string S[H];
  for (int n = 0; n < H; n++) {
    for (int k = 0; k < W; k++) {
      int counter = 0;
      if (S[n].at(k) == '#') {
        cout << "#";
      }
      if (n == 0) {
        if (k == 0) {
          if (S[n].at(k + 1) == '#') {
            counter++;
          }
          if (S[n + 1].at(k) == '#') {
            counter++;
          }
          if (S[n + 1].at(k + 1) == '#') {
            counter++;
          }
          cout << counter;
        } else if (k == W - 1) {
          if (S[n].at(k - 1) == '#') counter++;
          if (S[n + 1].at(k - 1) == '#') counter++;
          if (S[n + 1].at(k) == '#') counter++;
          cout << counter << endl;
        } else {
          if (S[n].at(k - 1) == '#') {
            counter++;
          }
          if (S[n].at(k + 1) == '#') counter++;
          if (S[n + 1].at(k - 1) == '#') counter++;
          if (S[n + 1].at(k) == '#') counter++;
          if (S[n + 1].at(k + 1) == '#') counter++;
          cout << counter;
        }
      } else if (n == H - 1) {
        if (k == 0) {
          if (S[n - 1].at(k) == '#') counter++;
          if (S[n - 1].at(k + 1) == '#') counter++;
          if (S[n].at(k + 1) == '#') counter++;
          cout << counter;
        } else if (k == W - 1) {
          if (S[n - 1].at(k - 1) == '#') counter++;
          if (S[n - 1].at(k) == '#') counter++;
          if (S[n].at(k - 1) == '#') counter++;
          cout << counter << endl;
        } else {
          if (S[n - 1].at(k - 1) == '#') counter++;
          if (S[n - 1].at(k) == '#') counter++;
          if (S[n - 1].at(k + 1) == '#') counter++;
          if (S[n].at(k - 1) == '#') counter++;
          if (S[n].at(k + 1) == '#') counter++;
          cout << counter;
        }
      } else {
        if (k == 0) {
          if (S[n - 1].at(k) == '#') counter++;
          if (S[n - 1].at(k + 1) == '#') counter++;
          if (S[n].at(k + 1) == '#') counter++;
          if (S[n + 1].at(k) == '#') counter++;
          if (S[n + 1].at(k + 1) == '#') counter++;
          cout << counter;
        } else if (k == W - 1) {
          if (S[n - 1].at(k - 1) == '#') counter++;
          if (S[n - 1].at(k) == '#') counter++;
          if (S[n].at(k - 1) == '#') counter++;
          if (S[n + 1].at(k - 1) == '#') counter++;
          if (S[n + 1].at(k) == '#') counter++;
          cout << counter << endl;
        } else {
          if (S[n - 1].at(k - 1) == '#') counter++;
          if (S[n - 1].at(k) == '#') counter++;
          if (S[n - 1].at(k + 1) == '#') counter++;
          if (S[n].at(k - 1) == '#') counter++;
          if (S[n].at(k + 1) == '#') counter++;
          if (S[n + 1].at(k - 1) == '#') counter++;
          if (S[n + 1].at(k) == '#') counter++;
          if (S[n + 1].at(k + 1) == '#') counter++;
          cout << counter;
        }
      }
    }
  }
}
