h, w = map(int, input().split())
s = [[j for j in input()] for i in range(h)]

for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            tmp = 0
            for k in range(max(0, i-1), min(i+2, h)):
                tmp += s[k][(max(0, j-1)) : min(j+2, w)].count('#')
            s[i][j] = str(tmp)

for s_ in s:
    print(''.join(s_))