#include <bits/stdc++.h>
using namespace std;
int join(vector<int> &p, vector<int> &q, int a, int b) {
  int ra, rb;
  for (ra = 0; a != p[a]; a = p[a], ra++)
    ;
  for (rb = 0; b != p[b]; b = p[b], rb++)
    ;
  if (a == b) return 0;
  int x = !q[a] || !q[b] ? 0 : q[a] + q[b];
  if (ra > rb) {
    p[b] = a;
    q[a] = x;
    q[b] = 0;
  } else {
    p[a] = b;
    q[b] = x;
    q[a] = 0;
  }
  return 1;
}
int main(int argc, char **argv) {
  cin.tie(NULL);
  int n, m, k;
  cin >> n >> m >> k;
  vector<string> s(n);
  vector<int> p(n * m, -1), q(n * m);
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int i = 0, a = 0; i < n; i++) {
    for (int j = 0; j < m; j++, a++) {
      if (s[i][j] == '*') continue;
      p[a] = a;
      q[a] = i > 0 && i < n - 1 && j > 0 && j < m - 1 ? 1 : 0;
      if (i > 0 && p[a - m] >= 0) join(p, q, a, a - m);
      if (j > 0 && p[a - 1] >= 0) join(p, q, a, a - 1);
    }
  }
  vector<pair<int, int>> r;
  for (int a = 0; a < n * m; a++) {
    if (!q[a]) continue;
    r.push_back({q[a], a});
  }
  sort(r.begin(), r.end());
  int sum = 0;
  vector<bool> t(n * m);
  k = r.size() - k;
  for (int i = 0; i < k; i++) {
    sum += r[i].first;
    t[r[i].second] = true;
  }
  cout << sum << endl;
  for (int i = 0, a = 0; i < n; i++) {
    for (int j = 0; j < m; j++, a++) {
      if (p[a] < 0) {
        cout << s[i][j];
        continue;
      }
      int b;
      for (b = a; b != p[b]; b = p[b])
        ;
      cout << (t[b] ? '*' : '.');
    }
    cout << endl;
  }
  return 0;
}
