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