#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> G(1);
vector<vector<int>> newG(1);
vector<vector<int>> vis(1);
struct st {
  int val, i, j;
};
vector<st> val;
int n, m, k;
void inittDFS(int i, int j) {
  vis[i][j] = 1;
  if (i > 0) {
    if (vis[i - 1][j] == 0 && G[i - 1][j] == 0) inittDFS(i - 1, j);
  }
  if (i + 1 <= n + 1) {
    if (vis[i + 1][j] == 0 && G[i + 1][j] == 0) inittDFS(i + 1, j);
  }
  if (j > 0) {
    if (vis[i][j - 1] == 0 && G[i][j - 1] == 0) inittDFS(i, j - 1);
  }
  if (j + 1 <= m + 1) {
    if (vis[i][j + 1] == 0 && G[i][j + 1] == 0) inittDFS(i, j + 1);
  }
  G[i][j] = 1;
}
void DFS(int i, int j, int link) {
  vis[i][j] = 1;
  val[link].val++;
  if (i > 0) {
    if (vis[i - 1][j] == 0 && G[i - 1][j] == 0) DFS(i - 1, j, link);
  }
  if (i + 1 <= n + 1) {
    if (vis[i + 1][j] == 0 && G[i + 1][j] == 0) DFS(i + 1, j, link);
  }
  if (j > 0) {
    if (vis[i][j - 1] == 0 && G[i][j - 1] == 0) DFS(i, j - 1, link);
  }
  if (j + 1 <= m + 1) {
    if (vis[i][j + 1] == 0 && G[i][j + 1] == 0) DFS(i, j + 1, link);
  }
}
bool srt(st a, st b) { return (a.val < b.val); }
int main() {
  ifstream fi("input.txt");
  cin >> n >> m >> k;
  G.resize(n + 2);
  newG.resize(n + 2);
  G[0].resize(m + 2);
  G[n + 1].resize(m + 2);
  vis.resize(n + 2);
  newG[0].resize(m + 2);
  newG[n + 1].resize(m + 2);
  vis[0].resize(m + 2);
  vis[n + 1].resize(m + 2);
  for (int i = 1; i <= n; i++) {
    G[i].resize(m + 2);
    newG[i].resize(m + 2);
    vis[i].resize(m + 2);
    for (int j = 1; j <= m; j++) {
      char t;
      cin >> t;
      if (t == '*') G[i][j] = 1;
      newG[i][j] = G[i][j];
    }
  }
  inittDFS(0, 0);
  int link = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (G[i][j] == 0 && vis[i][j] == 0) {
        st vl;
        val.push_back(vl);
        val[link].i = i;
        val[link].j = j;
        val[link].val = 0;
        DFS(i, j, link);
        link++;
      }
    }
  }
  sort(val.begin(), val.end(), srt);
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      vis[i][j] = 0;
      G[i][j] = newG[i][j];
    }
  }
  for (int i = 0; i < val.size() - k; i++) {
    ans += val[i].val;
    inittDFS(val[i].i, val[i].j);
  }
  cout << ans << endl;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (G[i][j] == 1)
        cout << '*';
      else
        cout << '.';
    }
    cout << endl;
  }
}
