#include<iostream>
#include<string>
using namespace std;
char s[105][105] = { 0 };
int main() {int h, l;cin >> h >> l;for (int i = 1; i <= h; i++) {for (int j = 1; j <= l; j++) {cin >> s[i][j];}}for (int i = 1; i <= h; i++) {for (int j = 1; j <= l; j++) {if (s[i][j] == '*')cout << s[i][j];else {int count = 0;if (s[i - 1][j - 1] == '*')count++;if (s[i - 1][j] == '*')count++;if (s[i - 1][j + 1] == '*')count++;if (s[i][j - 1] == '*')count++;if (s[i][j + 1] == '*')count++;if (s[i + 1][j - 1] == '*')count++;if (s[i + 1][j] == '*')count++;if (s[i + 1][j + 1] == '*')count++;cout << count;}}cout << endl;}return 0;
}