#include<iostream>
#include<fstream>
#include<algorithm>

using namespace std;
char c;
int a[101][101];
int main()
{
  int n,m;    
  cin>>n>>m;
  for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)
	  {cin>>c;if(c=='#')a[i][j]=1;}
  for(int i=1;i<=n;i++)
  {
	for(int j=1;j<=m;j++)
	  if(a[i][j]==1)  {cout<<'#';continue;}
	    else
		  cout<<a[i][j-1]+a[i][j+1]+a[i-1][j]+a[i+1][j]+a[i+1][j+1]+a[i+1][j-1]+a[i-1][j+1]+a[i-1][j-1];
    cout<<endl;  
  }  
  return 0;
}