#include <bits/stdc++.h>
using namespace std;
int n, m, k;
char** c;
int** mp;
int br = 1;
int dx[4] = {0, 0, -1, 1};
int dy[4] = {1, -1, 0, 0};
bool unutra(int x, int y) {
  if (x < 0 || y < 0 || x >= n || y >= m) return false;
  return true;
}
map<int, int> gp;
vector<pair<int, int> > lake;
void bfs(int a, int b) {
  mp[a][b] = br;
  gp[br] = 1;
  bool ivica = false;
  if (a == 0 || b == 0 || a == n - 1 || b == m - 1) ivica = true;
  queue<pair<int, int> > q;
  q.push(make_pair(a, b));
  while (q.size()) {
    pair<int, int> pi = q.front();
    q.pop();
    int x = pi.first;
    int y = pi.second;
    for (int i = 0; i < 4; i++) {
      int x1 = x + dx[i];
      int y1 = y + dy[i];
      if (unutra(x1, y1) && mp[x1][y1] == 0 && c[x1][y1] == '.') {
        mp[x1][y1] = br;
        gp[br]++;
        q.push(make_pair(x1, y1));
        if (x1 == 0 || y1 == 0 || x1 == n - 1 || y1 == m - 1) ivica = true;
      }
    }
  }
  if (ivica == false) {
    lake.push_back(make_pair(gp[br], br));
  }
}
int main() {
  scanf("%d", &n);
  scanf("%d", &m);
  scanf("%d", &k);
  mp = new int*[n];
  c = new char*[n];
  for (int i = 0; i < n; i++) {
    c[i] = new char[m];
    mp[i] = new int[m];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> c[i][j];
      mp[i][j] = 0;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (c[i][j] == '.' && mp[i][j] == 0) {
        bfs(i, j);
        br++;
      }
    }
  }
  sort(lake.begin(), lake.end());
  int sum = 0;
  int f = lake.size();
  f -= k;
  gp.clear();
  for (int i = 0; i < f; i++) {
    sum += lake[i].first;
    gp[lake[i].second] = 1;
  }
  cout << sum << endl;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (c[i][j] == '.' && gp[mp[i][j]] == 1) {
        cout << '*';
      } else {
        cout << c[i][j];
      }
    }
    cout << endl;
  }
  return 0;
}
