H = int(input())
W = int(input())
name ={}
count = 0
for i in range(H):
  name[i] = input()
  for j in range(W):
    if name[i][j] ==".":
      count = 0
      for k in range(i-1,i+2):
        for l in range(j-1,j+2):
          if name[k][l] == "#":
            count += 1
      name[i][j] = count
for i in range(H):
  print(name[i])
            