#include <bits/stdc++.h>
using namespace std;
int main() {
  int hang = 0, lie = 0, i, j;
  scanf("%d%d", &hang, &lie);
  char a[hang][lie];
  for (i = 0; i < hang; ++i) {
    scanf("%s", a[i]);
  }
  int b[hang + 2][lie + 2];
  for (i = 0; i < hang + 2; ++i) {
    for (j = 0; j < lie + 2; ++j) b[i][j] = 0;
  }
  for (i = 0; i < hang; ++i) {
    for (j = 0; j < lie; ++j) {
      if (a[i][j] == 42) {
        ++b[i][j];
        ++b[i][j + 1];
        ++b[i][j + 2];
        ++b[i + 1][j];
        ++b[i + 1][j + 2];
        ++b[i + 2][j];
        ++b[i + 2][j + 1];
        ++b[i + 2][j + 2];
      }
    }
  }
  for (i = 0; i < hang; ++i) {
    for (j = 0; j < lie; ++j) {
      if (a[i][j] == 42)
        printf("*");
      else
        printf("%d", b[i + 1][j + 1]);
    }
    if (i != hang - 1) printf("\n");
  }
  return 0;
}
