#include <bits/stdc++.h>
using namespace std;
bool b1[105][105]={0};
int main(){
	int a,b;
	char a1;
	cin >> a >> b;
	for (int i=1;i<=a;i++)
	for (int j=1;j<=b;j++){
		cin >> a1;
		if (a1=='#') b1[i][j]=1;
	}
	for (int i=1;i<=a;i++){
		for (int j=1;j<=b;j++){
			if (b1[i][j]==1) printf("#");
			else printf("%d",b1[i+1][j+1]+b1[i+1][j-1]+b1[i+1][j]+b1[i][j+1]+b1[i][j-1]+b1[i-1][j+1]+b1[i-1][j]+b1[i-1][j-1]);
		}
		cout << endl;
	}
}