#include <bits/stdc++.h>
using namespace std;
bool visited[105][105];
bool visited1[105][105];
string arr[1005];
bool myComparison(const pair<pair<int, int>, int> &a,
                  const pair<pair<int, int>, int> &b) {
  return a.second < b.second;
}
int sizee = 0;
int n, m;
void dfs(int starti, int startj) {
  if (starti >= n - 1 || startj >= m - 1 || starti < 1 || startj < 1) {
    if (arr[starti][startj] == '.') sizee = 999999;
    return;
  }
  if (visited[starti][startj] == true) return;
  visited[starti][startj] = true;
  sizee++;
  dfs(starti - 1, startj);
  dfs(starti, startj - 1);
  dfs(starti + 1, startj);
  dfs(starti, startj + 1);
}
void dfs1(int starti, int startj) {
  if (starti >= n - 1 || startj >= m - 1 || starti < 1 || startj < 1) {
    return;
  }
  if (visited1[starti][startj] == true) return;
  visited1[starti][startj] = true;
  arr[starti][startj] = '*';
  dfs1(starti - 1, startj);
  dfs1(starti, startj - 1);
  dfs1(starti + 1, startj);
  dfs1(starti, startj + 1);
}
int main() {
  memset(visited, false, sizeof(visited));
  cin >> n >> m;
  int k;
  cin >> k;
  vector<pair<pair<int, int>, int> > xxx;
  for (int i = 0; i < n; i++) cin >> arr[i];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (arr[i][j] == '*') visited[i][j] = true;
  for (int i = 1; i < n - 1; i++) {
    for (int j = 1; j < m - 1; j++) {
      sizee = 0;
      if (arr[i][j] == '.' && visited[i][j] == false) {
        dfs(i, j);
        if (sizee >= 999999) continue;
        xxx.push_back(make_pair(make_pair(i, j), sizee));
      }
    }
  }
  sort(xxx.begin(), xxx.end(), myComparison);
  int y = xxx.size() - k;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) visited1[i][j] = false;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (arr[i][j] == '*') visited1[i][j] = true;
  int ans = 0;
  for (int i = 0; i < y; i++) {
    int xx = xxx[i].first.first;
    int yy = xxx[i].first.second;
    ans += xxx[i].second;
    dfs1(xx, yy);
  }
  cout << ans << endl;
  for (int i = 0; i < n; i++) cout << arr[i] << endl;
}
