#include <bits/stdc++.h>
using namespace std;
char c[101][101];
int main() {
  int a, b, d = 0;
  cin >> a >> b;
  for (int i = 0; i < a; i++) {
    for (int j = 0; j < b; j++) {
      cin >> c[i][j];
    }
  }
  for (int i = 0; i < a; i++) {
    for (int j = 0; j < b; j++) {
      d = 0;
      if (c[i][j] == '*')
        cout << '*';
      else {
        if (c[i - 1][j + 1] == '*') d = d + 1;
        if (c[i][j + 1] == '*') d = d + 1;
        if (c[i + 1][j + 1] == '*') d = d + 1;
        if (c[i - 1][j] == '*') d = d + 1;
        if (c[i + 1][j] == '*') d = d + 1;
        if (c[i - 1][j - 1] == '*') d = d + 1;
        if (c[i][j - 1] == '*') d = d + 1;
        if (c[i + 1][j - 1] == '*') d = d + 1;
        cout << d;
      }
    }
    cout << endl;
  }
  return 0;
}
