#include <iostream>
#include <string>
using namespace std;
int a[10005][10005];
int b, c;
string d;
int main() {
cin >> b >> c;
for (int i = 1; i <= b; i++) {
cin >> d;
for (char ch : d) {
int j = 1;
if (ch == '*') {
a[i][j] = 10;
a[i - 1][j]++;
a[i][j - 1]++;
a[i + 1][j]++;
a[i][j + 1]++;
a[i - 1][j - 1]++;
a[i - 1][j + 1]++;
a[i + 1][j - 1]++;
a[i + 1][j + 1]++;
j++;
}
else j++;
}
}
for (int i = 1; i <= b; i++) {
for (int j = 1; j <= c; j++) {
if (a[i][j] >= 10) {
cout << "*";
}
else cout << a[i][j];
}
cout << endl;
}
return 0;
}