#include <iostream>
using namespace std ;
int main()
{
int x , y ;
cin >> x >> y ;
int a[x+2][y+2] = {0};
for (int i = 1 ; i <=x ; i++)
{
for(int j = 1 ; j <= y ; j++)
{
char c ;
cin >> c ;
if (c = '*')
a[i][j] = 10 ;
}
}
for (int i = 1 ; i <=x ; i++)
{
for(int j = 1 ; j <= y ; j++)
{
if (a[i][j]==10)
continue;
else
{
int num = 0 ;
for(int n = i - 1 ; n <= i + 1 ; n++)
{
for(int m = j - 1 ; m <= j+1 ; m++)
{
if (a[n][m]=10)
num++;
}
}
a[i][j] = num ;
}
}
}
for (int i = 1 ; i <=x ; i++)
{
for(int j = 1 ; j <= y ; j++)
{
if (a[i][j]==10)
cout << "*" ;
else
cout << a[i][j] ;
}
cout << endl ;
}
return 0 ;
}