h,w = map(int,input().split())
S = [['' for i in range(w+2)] for j in range(h+2)]
for i in range(h):
    S[i+1][1:w+1] = input()
for i in range(h):
    for j in range(w):
        if S[i+1][j+1]=='.':
            S[i+1][j+1] = str(1*(sum(S[k+i][j:j+3].count('#') for k in range(3))))
    print(*S[i+1][1:w+1],sep='')