#include <bits/stdc++.h>
using namespace std;
int n, m, k;
vector<string> g;
vector<vector<bool> > vis;
int lksz(int rw, int cl) {
  if (vis[rw][cl]) return 0;
  int c = 0;
  if (g[rw][cl] == '.') {
    c = 1;
    if (rw == 0 || rw == n - 1 || cl == 0 || cl == m - 1)
      return -10000;
    else {
      vis[rw][cl] = true;
      if (!vis[rw + 1][cl]) c += lksz(rw + 1, cl);
      if (!vis[rw - 1][cl]) c += lksz(rw - 1, cl);
      if (!vis[rw][cl + 1]) c += lksz(rw, cl + 1);
      if (!vis[rw][cl - 1]) c += lksz(rw, cl - 1);
    }
  }
  return c;
}
bool cmp(vector<int> a, vector<int> b) { return a[0] < b[0]; }
void lkrmv(int rw, int cl) {
  if (vis[rw][cl]) return;
  if (g[rw][cl] == '.') {
    vis[rw][cl] = true;
    g[rw][cl] = '*';
    if (!vis[rw + 1][cl]) lkrmv(rw + 1, cl);
    if (!vis[rw - 1][cl]) lkrmv(rw - 1, cl);
    if (!vis[rw][cl + 1]) lkrmv(rw, cl + 1);
    if (!vis[rw][cl - 1]) lkrmv(rw, cl - 1);
  }
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> n >> m >> k;
  vis.assign(n, vector<bool>(m, false));
  g.assign(n, "");
  for (int i = 0; i < n; i++) cin >> g[i];
  vector<vector<int> > lk;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (g[i][j] == '.' && !vis[i][j]) {
        int tsz = lksz(i, j);
        if (tsz > 0) lk.push_back({tsz, i, j});
      }
    }
  vis.assign(n, vector<bool>(m, false));
  sort(lk.begin(), lk.end(), cmp);
  int r = 0;
  while (lk.size() > k) {
    r += lk[0][0];
    lkrmv(lk[0][1], lk[0][2]);
    lk.erase(lk.begin());
  }
  cout << r << endl;
  for (int i = 0; i < n; i++) cout << g[i] << endl;
}
