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