#include<bits/stdc++.h>
using namespace std;
long long x,y,s;
string a[210];
int main(){
	cin>>x>>y;
	for(int i=1;i<=x;i++)
		cin>>a[i];
	for(int i=1;i<=x;i++){
		for(int j=0;j<y;j++){
			if(a[i][j]=='#'){
				cout<<a[i][j];
				continue;
			} 
			if(a[i+1][j]=='#')s++;
			if(a[i-1][j]=='#')s++;
			if(a[i+1][j+1]=='#')s++;
			if(a[i][j+1]=='#')s++;
			if(a[i-1][j+1]=='#')s++;
			if(a[i+1][j-1]=='#')s++;
			if(a[i][j-1]=='#')s++;
			if(a[i-1][j-1]=='#')s++;
			cout<<s;
			s=0;
		}
		cout<<endl;
	}
	return 0;
}
/*

*/