// luogu-judger-enable-o2
#include<bits/stdc++.h>

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