a,b=map(int,input().split())
s=[input()for i in range(a)]
for i in range(a):
    for j in range(b):
        c=0
        if s[i][j]==".":
            p=s[i]
            s[i]=p[:j]+str(sum([t[max(0,j-1):min(b,j+2)].count("#")for t in s[max(0,i-1):min(a,i+2)]]))+p[j+1:]
for i in range(a):
    print(s[i])