H,W = (int(i) for i in input().split())

original = [input() for i in range(H)]
sujimaru = [[0 for i in range(W+2)for j in range(H+2)]]

for j in range(H):
    for i in range(W):
        if(original[i][j] == "#"):
            sujimaru[i][j] += 1
            sujimaru[i+1][j] += 1
            sujimaru[i+2][j] += 1
            sujimaru[i][j+1] += 1
            sujimaru[i+2][j+1] += 1
            sujimaru[i][j+2] += 1
            sujimaru[i+1][j+2] += 1
            sujimaru[i+2][j+2] += 1

d = [""]*H
for j in range(H):
    for i in range(W):
        if(original[j][i] == "."):
            d[j] += str(sujimaru[j+1][i+1])
        else:
            d[j] += "#"

for s in d:
    print(s)