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