#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int h, w;
  cin >> h >> w;
  string s[h];
  for (int i = 0; i < h; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '.') {
        int n = 0;
        for (int k = -1; k <= 1; k++) {
          for (int l = -1; l <= 1; l++) {
            if (s[k][l] == '#') {
              n++;
            }
          }
        }
        s[i][j] = n;
      }
    }
  }
  for (int i = 0; i < h; i++) {
    cout << s[i];
  }
  cout << endl;
  return 0;
}
