#include <bits/stdc++.h>
int main() {
  char a[52][52];
  int b, c, d[55][55];
  scanf("%d%d", &b, &c);
  for (int i = 0; i < b; i++) {
    scanf("%s", a[i]);
  }
  for (int i = 0; i < b; i++) {
    for (int j = 0; j < c; j++) {
      if (a[i][j] == '#') {
        d[i + 1][j + 1]++;
        d[i + 1][j + 2]++;
        d[i][j]++;
        d[i + 1][j]++;
        d[i + 2][j]++;
        d[i][j + 2]++;
        d[i + 2][j + 1]++;
        d[i + 2][j + 2]++;
        d[i][j + 1]++;
      }
    }
  }
  for (int i = 0; i < b; i++) {
    for (int j = 0; j < c; j++) {
      if (a[i][j] == '#')
        printf("#");
      else
        printf("%d", d[i + 1][j + 1]);
    }
    printf("\n");
  }
  return 0;
}
