#include <iostream>
#include <string>
using namespace std;

int searchBomb(string *(grid)[], int m, int n, int maxH, int maxW) {
  if (grid[m][n] == "#") {
    return 0;
  }
  int countBomb = 0;
  deltaArrayM[4] = {1,0,-1,0};
  deltaArrayN[4] = {0,1,0,-1};
  for (int i=0; i < 4; ++i) {
    deltaM = m + deltaArrayM[i];
    deltaN = n + deltaArrayN[i];
    if ((deltaM < 0) || (deltaM > maxH)) {
      continue;
    }
    else if ((deltaN < 0) || (deltaN > maxW)) {
      continue;
    }
    else {
      if (grid[deltaM][deltaN] == "#") {
        ++countBomb;
      }
    }
  }
  grid[m][n] = countBomb;
}
      
    
int main() {
  int H, W;
  cin >> H >> W;
  string S[H];
  for (int i=0; i < H; ++i) {
    cin >> S[i];
  }
  for (int i=0; i < H; ++i) {
    for (int j=0; j < W; ++j) {
      searchBomb(S, i, j, H, W);
    }
  }
  for (int i=0; i < H; ++i) {
    cout << S[i] << "\n";
  }
}
  
  