#include <bits/stdc++.h>
using namespace std;
struct lake {
  vector<int> x, y;
  int v;
  int valid;
} lakes[2505];
int n, m, k;
int cnt;
char maps[55][55];
int vis[55][55];
void dfs(int x, int y) {
  if (x < 0 || x >= n || y < 0 || y >= m) {
    return;
  }
  if (vis[x][y]) {
    return;
  }
  if (maps[x][y] == '*') {
    return;
  }
  vis[x][y] = 1;
  lakes[cnt].v++;
  lakes[cnt].x.push_back(x);
  lakes[cnt].y.push_back(y);
  if (x == 0 || x == n - 1 || y == 0 || y == m - 1) {
    lakes[cnt].valid = 1;
  }
  dfs(x + 1, y);
  dfs(x - 1, y);
  dfs(x, y + 1);
  dfs(x, y - 1);
  return;
}
int cmp(lake a, lake b) {
  if (a.valid != b.valid) {
    return a.valid < b.valid;
  }
  return a.v < b.v;
}
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> maps[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (maps[i][j] == '.' && vis[i][j] == 0) {
        dfs(i, j);
        cnt++;
      }
    }
  }
  sort(lakes, lakes + cnt, cmp);
  int ans = 0;
  int vas = 0;
  for (int i = 0; i < cnt; i++) {
    if (!lakes[i].valid) {
      vas++;
    }
  }
  for (int i = 0; i < vas - k; i++) {
    for (int j = 0; j < lakes[i].v; j++) {
      maps[lakes[i].x[j]][lakes[i].y[j]] = '*';
      ans++;
    }
  }
  cout << ans << "\n";
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cout << maps[i][j];
    }
    cout << "\n";
  }
}
