#include <bits/stdc++.h>
using namespace std;
int n, m, k, ans;
bool b, visit[55][55];
char x[55][55];
vector<pair<int, pair<int, int> > > v;
int check(int i, int j) {
  if (x[i][j] == '*' || visit[i][j]) return 0;
  if (i < 0 || i == n || j < 0 || j == m) return 0;
  if (!i || !j || i + 1 == n || j + 1 == m) b = 0;
  visit[i][j] = 1;
  return 1 + check(i + 1, j) + check(i - 1, j) + check(i, j + 1) +
         check(i, j - 1);
}
void change(int i, int j) {
  if (x[i][j] == '*') return;
  if (i < 0 || i == n || j < 0 || j == m) return;
  x[i][j] = '*';
  change(i + 1, j);
  change(i - 1, j);
  change(i, j + 1);
  change(i, j - 1);
}
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> x[i][j];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (!visit[i][j] && x[i][j] == '.') {
        b = 1;
        int s = check(i, j);
        if (b) v.push_back({s, {i, j}});
      }
    }
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < max(0, (int)v.size() - k); i++)
    ans += v[i].first, change(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 << x[i][j];
    cout << endl;
  }
  return 0;
}
