#include<iostream>
using namespace std;
char c[101][101];
int d[101][101];
int main()
{
	int a,b;
	cin>>a>>b;
	for(int i=1;i<=a;i++)
	{
		for(int o=1;o<=b;o++)
		{
			cin>>c[i][o];
			if(c[i][o]=='#')
			{
				d[i][o]=-100;
				d[i+1][o]+=1;
				d[i+1][o+1]+=1;
				d[i+1][o-1]+=1;
				d[i][o+1]+=1;
				d[i][o-1]+=1;
				d[i-1][o]+=1;
				d[i-1][o+1]+=1;
				d[i-1][o-1]+=1;
			}
		}
	}
	for(int i=1;i<=a;i++)
	{
		for(int o=1;o<=b;o++)
		{
			if(d[i][o]<0)
				cout<<"#";
			else
				cout<<d[i][o];
		}
		cout<<"\n";
	}
}