h,w = map(int, input().strip().split())
arr = []
arr = [list(input()) for i in range(h)]
for i in range(h):
  for j in range(w):
    if arr[i][j] == ".":
      u = max(i-1,0)
      d = min(i+2,h)
      l = max(j-1,0)
      r = min(j+2,w)
      n = 0
      for line in arr[u:d]:
          n += line[l:r].count("#")
      arr[i][j] = str(n)

for line in arr:
    print("".join(line))