#include <bits/stdc++.h>
using namespace std;
char ar[100][100];
int vis[100][100];
int n, m, k;
void dfs2(int i, int j) {
  if (ar[i][j] == '*') return;
  ar[i][j] = '*';
  dfs2(i - 1, j);
  dfs2(i + 1, j);
  dfs2(i, j - 1);
  dfs2(i, j + 1);
}
int dfs(int i, int j) {
  if (i < 0 || j < 0 || i > n - 1 || j > m - 1) return -1000;
  if (ar[i][j] == '*') return 0;
  if (vis[i][j] == 1) return 0;
  vis[i][j] = 1;
  return 1 + dfs(i - 1, j) + dfs(i + 1, j) + dfs(i, j - 1) + dfs(i, j + 1);
}
vector<int> v;
vector<int> a;
vector<int> b;
vector<int> v2;
vector<int> an;
string s;
int main() {
  scanf("%d", &n);
  scanf("%d", &m);
  scanf("%d", &k);
  char c;
  for (int i = 0; i < n; i++) {
    cin >> s;
    for (int j = 0; j < m; j++) ar[i][j] = s[j];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (ar[i][j] == '.') {
        int val = dfs(i, j);
        if (val > 0) {
          v.push_back(val);
          a.push_back(i);
          b.push_back(j);
          v2.push_back(val);
        }
      }
    }
  }
  sort(v2.begin(), v2.end());
  int ct = (int)(v.size()) - k;
  int p = 0;
  while (ct > 0) {
    an.push_back(v2[p]);
    p++;
    ct--;
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) vis[i][j] = 0;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int f = 0;
    for (int j = 0; j < m; j++) {
      if (ar[i][j] == '.' && vis[i][j] == 0) {
        int val = dfs(i, j);
        if (find(an.begin(), an.end(), val) != an.end()) {
          dfs2(i, j);
          ans += val;
          an.erase(find(an.begin(), an.end(), val));
        }
      }
    }
  }
  printf("%d\n", ans);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) printf("%c", ar[i][j]);
    printf("\n");
  }
  return 0;
}
