H,W=map(int,input().split())
S=[list(input()) for i in range(H)]

dx=[0, -1, 1]
dy=[0, -1, 1]

for i in range(H):
	for j in range(W):
		cnt=0
		if S[i][j]!="#":
			for x in dx:
				for y in dy:
					if 0<=i+y<H and 0<=j+x<W:
						if S[i+y][j+x]=="#":
							cnt+=1
			S[i][j]=str(cnt)				
		
for s in S:
	print("".join(s))
