#include <bits/stdc++.h>
using namespace std;
int n,m,i,j;
char a[120][120];
int xx[]={-1,-1,0,1,1,1,0,-1},yy[]={0,1,1,1,0,-1,-1,-1};
void jishu(int x,int y)
{
int k,sum=0;
for (k=0;k<8;k++)
{
if (a[x+xx[k]][y+yy[k]]=='*')
sum++;
}
cout<<sum;
}
int main ()
{
cin>>n>>m;
for (i=1;i<=n;i++)
{
for (j=1;j<=m;j++)
{
cin>>a[i][j];
}
}
for (i=1;i<=n;i++)
{
for (j=1;j<=m;j++)
{
if (a[i][j]=='?')
{if (j%3!=0)
jishu(i,j);
else
{if (i!=n)
{jishu(i,j);cout<<endl;
}
else
jishu(i,j);
}
}
else
{ if (j%3!=0)
cout<<'*';
else
{
if (i!=n)
cout<<'*'<<endl;
else
cout<<'*';
}
}
}
}
}