#include<bits/stdc++.h>
using namespace std;
const int N = 101;
bool w[N][N];//1silei,0meiyou
int a,b;
char c;
int main(){
cin>>a>>b;
for(int i=0;i<N;i++){
for(int j=0;j<N;j++){
w[i][j]=0;
}
}//chushihua
for(int i=0;i<a;i++){
for(int j=0;j<b;j++){
cin>>c;
if(c=='*') w[i][j]=1;
}
}
/*for(int i=0;i<a;i++){
for(int j=0;j<b;j++){
cout<<w[i][j]<<" ";
}
cout<<endl;
}//测试,记得删 */
for(int i=0;i<a;i++){
for(int j=0;j<b;j++){
if(w[i][j]==1) cout<<"*";
else cout<<w[i-1][j-1]+w[i-1][j]+w[i-1][j+1]+w[i][j-1]+w[i][j+1]+w[i+1][j-1]+w[i+1][j]+w[i+1][j+1];
}
cout<<endl;
}
return 0;
}