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