#include<bits/stdc++.h>
using namespace std;
bool a[102][102];
int main(){
int l,b,c=0
;cin>>l>>b;
string st;
for(int i=1;i<=l;i++){
cin>>st;
for(int j=1;j<=b;j++)a[i][j]=st[j-1]=='*';
}
for(int i=1;i<=l;i++){
for(int j=1;j<=b;j++){
c=0;
if(a[i][j]==1){
cout<<"*";
break;
}
c=a[i][j-1]+a[i-1][j]+a[i][j+1]+a[i+1][j]+a[i-1][j-1]+a[i+1][j-1]+a[i+1][j+1]+a[i-1][j+1];
cout<<c;
}
cout<<endl;
}
}