#include <bits/stdc++.h>
using namespace std;
int n, m, k;
string a[50];
bool visited[51][51];
int dfs(int i, int j) {
  if (i == n - 1 || i == 0 || j == 0 || j == m - 1) return -3000;
  visited[i][j] = true;
  int l = 0, r = 0, d = 0, u = 0;
  if (!visited[i][j - 1] && a[i][j - 1] == '.') l = dfs(i, j - 1);
  if (!visited[i][j + 1] && a[i][j + 1] == '.') r = dfs(i, j + 1);
  if (!visited[i + 1][j] && a[i + 1][j] == '.') u = dfs(i + 1, j);
  if (!visited[i - 1][j] && a[i - 1][j] == '.') d = dfs(i - 1, j);
  return 1 + l + r + d + u;
}
void mland(int i, int j) {
  a[i][j] = '*';
  if (a[i][j - 1] == '.') mland(i, j - 1);
  if (a[i][j + 1] == '.') mland(i, j + 1);
  if (a[i - 1][j] == '.') mland(i - 1, j);
  if (a[i + 1][j] == '.') mland(i + 1, j);
}
int main() {
  cin >> n >> m >> k;
  int num_lakes = 0;
  vector<pair<int, pair<int, int>>> v;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    for (int j = 0; j < m; j++) visited[i][j] = false;
  }
  for (int i = 1; i < n - 1; i++) {
    for (int j = 1; j < m - 1; j++) {
      if (a[i][j] == '.' && !visited[i][j]) {
        int num_water = dfs(i, j);
        if (num_water > 0) {
          num_lakes++;
          v.push_back(make_pair(num_water, make_pair(i, j)));
        }
      }
    }
  }
  sort(v.begin(), v.end());
  int ans = 0, reduce = num_lakes - k;
  for (int i = 0; i < reduce; i++) {
    ans = ans + v[i].first;
    mland(v[i].second.first, v[i].second.second);
  }
  cout << ans << endl;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cout << a[i][j];
    }
    cout << endl;
  }
  return 0;
}
