#include <bits/stdc++.h>
using namespace std;
const int maxN = 100;
char a[maxN][maxN], mark[maxN][maxN];
bool ocean = false;
queue<pair<int, int> > q;
void adj(int i, int j) {
  if (mark[i][j] == false && a[i][j] != '*') {
    if (a[i][j] == '.') {
      mark[i][j] = true;
      q.push(make_pair(i, j));
    } else
      ocean = true;
  }
}
vector<pair<int, vector<pair<int, int> > > > lakes;
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> a[i][j];
  cerr << a[0][0];
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (mark[i][j] == false && a[i][j] == '.') {
        ocean = false;
        q.push(make_pair(i, j));
        mark[i][j] = true;
        int size = 0;
        vector<pair<int, int> > v;
        while (!q.empty()) {
          size++;
          int i = q.front().first, j = q.front().second;
          v.push_back(q.front());
          q.pop();
          adj(i - 1, j);
          adj(i + 1, j);
          adj(i, j - 1);
          adj(i, j + 1);
        }
        if (ocean == false) lakes.push_back(make_pair(size, v));
      }
  sort(lakes.begin(), lakes.end());
  int out = 0;
  for (int i = 0; i < lakes.size() - k; i++) {
    out += lakes[i].first;
    for (int j = 0; j < lakes[i].second.size(); j++) {
      int x = lakes[i].second[j].first, y = lakes[i].second[j].second;
      a[x][y] = '*';
    }
  }
  cout << out << '\n';
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) cout << a[i][j];
    cout << '\n';
  }
}
