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