#include <bits/stdc++.h>
using namespace std;
int main() {
  int h, w, cnt[55][55];
  cin >> h >> w;
  char s[55][55];
  for (int i = 0; i < 52; i++) {
    for (int j = 0; j < 52; j++) {
      s[i][j] = 0;
      cnt[i][j] = 0;
    }
  }
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      cin >> s[i][j];
    }
  }
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      cnt[i][j] = 0;
      if (s[i][j] == '.') {
        if (s[i - 1][j - 1] == '#') cnt[i][j]++;
        if (s[i - 1][j] == '#') cnt[i][j]++;
        if (s[i - 1][j + 1] == '#') cnt[i][j]++;
        if (s[i][j - 1] == '#') cnt[i][j]++;
        if (s[i][j] == '#') cnt[i][j]++;
        if (s[i][j + 1] == '#') cnt[i][j]++;
        if (s[i + 1][j - 1] == '#') cnt[i][j]++;
        if (s[i + 1][j] == '#') cnt[i][j]++;
        if (s[i + 1][j + 1] == '#') cnt[i][j]++;
        s[i][j] = 0;
      }
    }
  }
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      if (s[i][j] != 0) cout << s[i][j];
      if (cnt[i][j] != 0) cout << cnt[i][j];
    }
    cout << endl;
  }
  return 0;
}
