#include <bits/stdc++.h>
using namespace std;
int n, m;
int mat[102][102];
int visited[102][102];
void dfs1(int i, int j, int v) {
  if (i < 0 || i >= n || j < 0 || j >= m) return;
  if (visited[i][j] == v) return;
  if (mat[i][j] == 1) return;
  visited[i][j] = v;
  mat[i][j] = v + 1;
  dfs1(i - 1, j, v);
  dfs1(i + 1, j, v);
  dfs1(i, j - 1, v);
  dfs1(i, j + 1, v);
}
int dfs(int i, int j) {
  if (i < 0 || i >= n || j < 0 || j >= m) return 0;
  if (visited[i][j] == 1) return 0;
  if (mat[i][j] == 1) return 0;
  visited[i][j] = 1;
  int c = 1;
  c += dfs(i - 1, j);
  c += dfs(i + 1, j);
  c += dfs(i, j - 1);
  c += dfs(i, j + 1);
  return c;
}
int main() {
  int k;
  cin >> n >> m >> k;
  string str;
  for (int i = 0; i < n; i++) {
    cin >> str;
    for (int j = 0; j < m; j++) {
      if (str[j] == '.')
        mat[i][j] = 0;
      else
        mat[i][j] = 1;
    }
  }
  memset(visited, 0, sizeof(visited));
  for (int i = 0; i < m; i++) dfs1(0, i, 1);
  for (int i = 0; i < m; i++) dfs1(n - 1, i, 1);
  for (int i = 0; i < n; i++) dfs1(i, 0, 1);
  for (int i = 0; i < n; i++) dfs1(i, m - 1, 1);
  vector<pair<int, pair<int, int> > > aa;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (!visited[i][j] && mat[i][j] == 0)
        aa.push_back(make_pair(dfs(i, j), make_pair(i, j)));
    }
  }
  sort(aa.begin(), aa.end());
  int l = aa.size(), ans = 0;
  int ma = l - k;
  for (int i = 0; i < ma; i++) {
    ans += aa[i].first;
    dfs1(aa[i].second.first, aa[i].second.second, 2);
  }
  cout << ans << endl;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (mat[i][j] == 1 || mat[i][j] == 3)
        cout << '*';
      else
        cout << '.';
    }
    cout << endl;
  }
  return 0;
}
