#include <bits/stdc++.h>
using namespace std;
int n, m, k;
vector<vector<char> > grid;
map<pair<int, int>, bool> visited;
int lakeCounter = 0;
bool isLake = 1;
map<int, vector<pair<int, int> > > number;
int cellCounter = 0;
int counter = 0;
bool check(int i, int j) { return (i >= 0 && i < n && j >= 0 && j < m); }
void dfs(int i, int j) {
  if (check(i, j)) {
    if (!visited[{i, j}] && grid[i][j] == '.') {
      cellCounter++;
      visited[{i, j}] = 1;
      if (i == 0 || i == n - 1 || j == 0 || j == m - 1) {
        isLake = 0;
      }
      dfs(i, j - 1);
      dfs(i, j + 1);
      dfs(i + 1, j);
      dfs(i - 1, j);
    }
  }
}
void mark(int i, int j) {
  if (check(i, j)) {
    if (visited[{i, j}] && grid[i][j] == '.') {
      counter++;
      visited[{i, j}] = 0;
      grid[i][j] = '*';
      mark(i, j - 1);
      mark(i, j + 1);
      mark(i + 1, j);
      mark(i - 1, j);
    }
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) {
    vector<char> temp;
    char c;
    for (int j = 0; j < m; j++) {
      cin >> c;
      temp.push_back(c);
    }
    grid.push_back(temp);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (grid[i][j] == '.' && !visited[{i, j}]) {
        isLake = 1;
        cellCounter = 0;
        dfs(i, j);
        if (isLake) {
          lakeCounter++;
          number[cellCounter].push_back({i, j});
        }
      }
    }
  }
  for (auto it = number.begin(); it != number.end(); it++) {
    for (int i = 0; i < it->second.size(); i++) {
      if (lakeCounter > k) {
        lakeCounter--;
        mark(it->second[i].first, it->second[i].second);
      }
    }
  }
  cout << counter << endl;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cout << grid[i][j];
    }
    cout << endl;
  }
  return 0;
}
