#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
const int N = 110;
vector<pii> v[N][N], pos;
vector<int> id, vec;
int color[N][N], n, m, res;
char a[N][N];
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
bool valid(int k, int p) {
  if (k < 0 || p < 0 || k > n + 1 || p > m + 1) return false;
  return true;
}
void f(int k, int p, int c, int d) {
  if (valid(k, p) == 0) return;
  color[k][p] = 1;
  v[c][d].push_back(pii(k, p));
  for (int i = 0; i < 4; i++) {
    if ((valid(k + dx[i], p + dy[i])) && color[k + dx[i]][p + dy[i]] == 0) {
      f(k + dx[i], p + dy[i], c, d);
    }
  }
}
void init() {
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      if (color[i][j] == 0) {
        f(i, j, i, j);
      }
    }
  }
}
bool cmp(int nn, int mn) { return vec[nn] < vec[mn]; }
int main() {
  int k;
  cin >> n >> m >> k;
  for (int i = 0; i <= n + 1; i++) {
    for (int j = 0; j <= m + 1; j++) {
      color[i][j] = 1;
      if (i == 0 || i == n + 1 || j == 0 || j == m + 1) color[i][j] = 0;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
      if (a[i][j] == '.') color[i][j] = 0;
    }
  }
  init();
  int t = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (v[i][j].size()) {
        vec.push_back(v[i][j].size());
        pos.push_back(pii(i, j));
        id.push_back(t);
        t++;
      }
    }
  }
  int len = vec.size();
  sort(id.begin(), id.end(), cmp);
  for (int i = 0; i < len - k; i++) {
    int x = pos[id[i]].first;
    int y = pos[id[i]].second;
    for (int j = 0; j < v[x][y].size(); j++) {
      a[v[x][y][j].first][v[x][y][j].second] = '*';
    }
    res += v[x][y].size();
  }
  cout << res << endl;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cout << a[i][j];
    }
    cout << endl;
  }
}
