#include<cstdio>
#define G(x,y) _G_[x*(100+1)+y]
using namespace std;
const int dir[8][2]={{0,-1},{0,1},{-1,0},{1,0},{-1,-1},{1,-1},{-1,1},{1,1}};
char _G_[(100+1)*(100+1)];
int main(){
int n,m;
scanf("%d%d",&n,&m);
for(int x=1;x<=n;x++)
for(int y=1;y<=m;y++)
scanf("%c",&(G(x,y)));
for(int x=1;x<=n;x++){
for(int y=1;y<=m;y++){
if(G(x,y)=='*'){printf("*");continue;}
int cnt=0;
for(int k=0;k<8;k++){
int xx=x+dir[k][0],yy=y+dir[k][1];
if(G(xx,yy)=='*')cnt++;
}
printf("%c",cnt+'0');
}
printf("\n");
}
return 0;
}