#include <bits/stdc++.h>
using namespace std;
const int INF = 1000 * 1000 * 1000;
const int MOD = 1000 * 1000 * 1000 + 7;
const long INF_L = 1000 * 1000 * 1000;
const long long INF_LL = 1LL * INF_L * INF_L;
const long long MOD_LL = 1000000000007LL;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int Abs(int a) { return (a > 0 ? a : -a); }
long long pow(long long n, long long a, long long mod) {
  long long res = 1;
  while (a) {
    if (a & 1) res = (res * n) % mod;
    n = (n * n) % mod;
    a >>= 1;
  }
  return res;
}
long long gcd(long long a, long long b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
const int N = 2010;
vector<vector<bool>> g, used;
int n, m;
vector<pair<int, pair<int, int>>> lakes;
bool isValid(int i, int j) { return (i >= 0 && i < n && j >= 0 && j < m); }
void dfsOcean(int i, int j) {
  used[i][j] = true;
  for (int d = 0; d < 4; ++d) {
    int ii = i + dx[d];
    int jj = j + dy[d];
    if (isValid(ii, jj) && g[ii][jj] && !used[ii][jj]) {
      dfsOcean(ii, jj);
    }
  }
}
int dfs(int i, int j) {
  used[i][j] = true;
  int size = 1;
  for (int d = 0; d < 4; ++d) {
    int ii = i + dx[d];
    int jj = j + dy[d];
    if (isValid(ii, jj) && g[ii][jj] && !used[ii][jj]) {
      size += dfs(ii, jj);
    }
  }
  return size;
}
void dfsMark(int i, int j) {
  used[i][j] = true;
  g[i][j] = false;
  for (int d = 0; d < 4; ++d) {
    int ii = i + dx[d];
    int jj = j + dy[d];
    if (isValid(ii, jj) && g[ii][jj] && !used[ii][jj]) {
      dfsMark(ii, jj);
    }
  }
}
int main() {
  int k;
  cin >> n >> m >> k;
  char c;
  g.assign(n, vector<bool>(m, false));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> c;
      g[i][j] = (c == '.');
    }
  }
  used.assign(n, vector<bool>(m, false));
  for (int i = 0; i < n; ++i) {
    if (!used[i][0] && g[i][0]) {
      dfsOcean(i, 0);
    }
    if (!used[i][m - 1] && g[i][m - 1]) {
      dfsOcean(i, m - 1);
    }
  }
  for (int i = 0; i < m; ++i) {
    if (!used[0][i] && g[0][i]) {
      dfsOcean(0, i);
    }
    if (!used[n - 1][i] && g[n - 1][i]) {
      dfsOcean(n - 1, i);
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (!used[i][j] && g[i][j]) {
        lakes.push_back(make_pair(dfs(i, j), make_pair(i, j)));
      }
    }
  }
  sort(lakes.begin(), lakes.end());
  used.assign(n, vector<bool>(m, false));
  int ans = 0;
  for (int i = 0; i < (int)lakes.size() - k; ++i) {
    ans += lakes[i].first;
    dfsMark(lakes[i].second.first, lakes[i].second.second);
  }
  cout << ans << endl;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cout << (g[i][j] ? '.' : '*');
    }
    cout << endl;
  }
  return 0;
}
