#include <bits/stdc++.h>
using namespace std;
const long long inf = 1000000007;
const int N = 105;
int n, m, k, nl, d[N][N], ok;
struct point {
  int x, y;
  point(){};
  point(int x, int y) : x(x), y(y) {}
};
string a[N];
vector<point> l[N * N];
int s[N * N], p[N * N];
void input() {
  cin >> n >> m >> k;
  getline(cin, a[0]);
  for (int i = 0; i < n; i++) {
    getline(cin, a[i]);
  }
}
int vx[] = {0, 1, 0, -1};
int vy[] = {-1, 0, 1, 0};
int check(int x, int y) { return x >= 0 && x < n && y >= 0 && y < m; }
void dfs(int x, int y) {
  l[nl].push_back(point(x, y));
  s[nl]++;
  d[x][y] = 1;
  for (int k = 0; k < 4; k++) {
    int u = x + vx[k];
    int v = y + vy[k];
    if (!check(u, v)) {
      ok = 0;
      continue;
    }
    if (a[u][v] != '.' || d[u][v]) continue;
    dfs(u, v);
  }
}
int cmp(int x, int y) { return s[x] < s[y]; }
void solve() {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] == '.' && !d[i][j]) {
        l[nl].clear();
        s[nl] = 0;
        p[nl] = nl;
        ok = 1;
        dfs(i, j);
        if (ok) nl++;
      }
    }
  }
  sort(p, p + nl, cmp);
  int ans = 0;
  for (int i = 0; i < nl - k; i++) {
    ans += s[p[i]];
    for (int j = 0; j < l[p[i]].size(); j++) {
      int u = l[p[i]][j].x;
      int v = l[p[i]][j].y;
      a[u][v] = '*';
    }
  }
  cout << ans << endl;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cout << a[i][j];
    }
    cout << endl;
  }
}
int main() {
  int test = 1;
  while (test--) {
    input();
    solve();
  }
  return 0;
}
