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