#include <bits/stdc++.h>
using namespace std;
int main() {
  int H, W;
  cin >> H >> W;
  int a[55][55];
  string S;
  for (int i = 0; i < H; ++i) {
    cin >> S;
    for (int j = 0; j < W; ++j) {
      if (S[j] == '#') {
        for (int k = i - 1; k <= i + 1; ++k) {
          ++a[k][j - 1];
          ++a[k][j];
          ++a[k][j + 1];
        }
        a[i][j] = -10;
      }
    }
  }
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      if (a[i][j] < 0)
        cout << '#';
      else
        cout << a[i][j];
    }
    cout << endl;
  }
  return 0;
}
