#include <bits/stdc++.h>
using namespace std;
int a[60][60];
int main() {
  int h, w;
  cin >> h >> w;
  char c;
  for (int i = 1; i <= h; i++) {
    for (int j = 1; i <= w; j++) {
      scanf("%c", &c);
      if (c == '#')
        a[i][j] = 1;
      else
        a[i][j] = 0;
    }
  }
  for (int i = 1; i <= h; i++) {
    for (int j = 1; i <= w; j++) {
      if (a[i][j] == 1)
        cout << "#";
      else {
        int s = 0;
        s = a[i - 1][j - 1] + a[i - 1][j] + a[i - 1][j + 1] + a[i][j + 1] +
            a[i][j - 1] + a[i + 1][j + 1] + a[i + 1][j] + a[i + 1][j - 1];
        cout << s;
      }
    }
    cout << endl;
  }
  return 0;
}
