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