#include<stdio.h>
char a[101][101];
int b[101][101];
int main()
{
int n, m, i, j;
scanf("%d%d", &n, &m);
for (i = 1; i < n + 1; i++)
for (j = 0; j < m + 1; j++)
scanf("%c", &a[i][j]);
for (i = 1; i < n + 1; i++)
for (j = 1; j < m + 1; j++)
if (a[i][j] == '*')
b[i][j] = '*';
else if ('?' == a[i][j])
for (int k = i - 1; k <= i + 1; k++)
for (int h = j - 1; h <= j + 1; h++)
if (a[k][h] == '*')
b[i][j]++;
for (i = 1; i < n + 1; i++)
{
for (j = 1; j < m + 1; j++)
if (b[i][j] == '*')
printf("*");
else
printf("%d", b[i][j]);
printf("\n");
}
return 0;
}