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