#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int arr[51][51] = {0}, visit[51][51] = {0};
vector<pair<int, pair<int, int> > > v;
int dfs(int a, int b, int count);
void make_land(int i, int j);
int main() {
  int i, j, sum = 0;
  char ch;
  cin >> n >> m >> k;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      cin >> ch;
      if (ch == '*') arr[i][j]++;
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (!visit[i][j] && !arr[i][j]) {
        int value = dfs(i, j, 0);
        if (value != -1) v.push_back(make_pair(value, make_pair(i, j)));
      }
    }
  }
  sort(v.begin(), v.end());
  int check = v.size();
  vector<pair<int, pair<int, int> > >::iterator it = v.begin();
  for (i = 0; i < v.size() - k; i++) {
    sum += it->first;
    int a = (it->second).first;
    int b = (it->second).second;
    make_land(a, b);
    it++;
  }
  cout << sum << endl;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (arr[i][j] == 1)
        cout << '*';
      else
        cout << '.';
    }
    cout << endl;
  }
}
int dfs(int i, int j, int count) {
  visit[i][j] = 1;
  if (count != -1) count++;
  if (i == n - 1 || j == m - 1 || i == 0 || j == 0) count = -1;
  if (i <= n - 1 && j - 1 >= 0 && !visit[i][j - 1] && !arr[i][j - 1])
    count = dfs(i, j - 1, count);
  if (i - 1 >= 0 && j <= m - 1 && !visit[i - 1][j] && !arr[i - 1][j])
    count = dfs(i - 1, j, count);
  if (i <= n - 1 && j + 1 <= m - 1 && !visit[i][j + 1] && !arr[i][j + 1])
    count = dfs(i, j + 1, count);
  if (i + 1 <= n - 1 && j <= m - 1 && !visit[i + 1][j] && !arr[i + 1][j])
    count = dfs(i + 1, j, count);
  return count;
}
void make_land(int i, int j) {
  arr[i][j] = 1;
  if (i <= n - 1 && j - 1 >= 0 && !arr[i][j - 1]) {
    make_land(i, j - 1);
  }
  if (i - 1 >= 0 && j <= m - 1 && !arr[i - 1][j]) {
    make_land(i - 1, j);
  }
  if (i <= n - 1 && j + 1 <= m - 1 && !arr[i][j + 1]) {
    make_land(i, j + 1);
  }
  if (i + 1 <= n - 1 && j <= m - 1 && !arr[i + 1][j]) {
    make_land(i + 1, j);
  }
}
