#include <bits/stdc++.h>
using namespace std;
long long maxm(long long a, long long b) {
  if (a > b) return a;
  return b;
}
long long minm(long long a, long long b) {
  if (a < b)
    return a;
  else
    return b;
}
long long binpow(long long a, long long b) {
  if (b == 0) return 1;
  long long prod = binpow(a, b / 2);
  if (b % 2 == 0)
    return (prod * prod);
  else
    return (((a * prod)) * prod);
}
int swap(int& a, int& b) {
  int temp = a;
  a = b;
  b = temp;
}
int findpar(vector<int>& dsu, int k) {
  if (dsu[k] == k || dsu[k] == -1) return dsu[k];
  dsu[k] = findpar(dsu, dsu[k]);
  return dsu[k];
}
void unon(vector<int>& dsu, vector<long long>& size, int a, int b) {
  if (findpar(dsu, a) == findpar(dsu, b)) return;
  int apr = findpar(dsu, a), bpr = findpar(dsu, b);
  int don = apr, rec = bpr;
  if (size[apr] > size[bpr]) swap(don, rec);
  dsu[don] = rec;
  size[rec] += size[don];
  return;
}
bool notedge(int i, int j, int n, int m) {
  if (i == 0 || i == n - 1 || j == 0 || j == m - 1) return false;
  return true;
}
void solve() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<vector<char>> grid(n, vector<char>(m));
  vector<int> dsu(m * n, -1);
  vector<long long> size(m * n, 1);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> grid[i][j];
      if (notedge(i, j, n, m) && grid[i][j] == '.') dsu[i * m + j] = i * m + j;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (grid[i][j] == '.' && notedge(i, j, n, m)) {
        if (i > 0) {
          if (grid[i - 1][j] == '.') {
            int ind = (i - 1) * m + j;
            if (findpar(dsu, ind) == -1 && findpar(dsu, i * m + j) != -1)
              dsu[findpar(dsu, i * m + j)] = -1;
            else if (findpar(dsu, ind) != -1 && findpar(dsu, i * m + j) != -1)
              unon(dsu, size, ind, i * m + j);
          }
        }
        if (i < n - 1) {
          if (grid[i + 1][j] == '.') {
            int ind = (i + 1) * m + j;
            if (findpar(dsu, ind) == -1 && findpar(dsu, i * m + j) != -1)
              dsu[findpar(dsu, i * m + j)] = -1;
            else if (findpar(dsu, ind) != -1 && findpar(dsu, i * m + j) != -1)
              unon(dsu, size, ind, i * m + j);
          }
        }
        if (j > 0) {
          if (grid[i][j - 1] == '.') {
            int ind = i * m + j - 1;
            if (findpar(dsu, ind) == -1 && findpar(dsu, i * m + j) != -1)
              dsu[findpar(dsu, i * m + j)] = -1;
            else if (findpar(dsu, ind) != -1 && findpar(dsu, i * m + j) != -1)
              unon(dsu, size, ind, i * m + j);
          }
        }
        if (j < m - 1) {
          if (grid[i][j + 1] == '.') {
            int ind = (i)*m + j + 1;
            if (findpar(dsu, ind) == -1 && findpar(dsu, i * m + j) != -1)
              dsu[findpar(dsu, i * m + j)] = -1;
            else if (findpar(dsu, ind) != -1 && findpar(dsu, i * m + j) != -1)
              unon(dsu, size, ind, i * m + j);
          }
        }
      }
    }
  }
  vector<pair<int, int>> ans;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++)
      if (findpar(dsu, i * m + j) == i * m + j)
        ans.push_back(make_pair(size[i * m + j], i * m + j));
  }
  sort(ans.begin(), ans.end());
  set<int> par;
  int sum = 0;
  for (int i = 0; i < ans.size() - k; i++) {
    sum += ans[i].first;
    par.insert(ans[i].second);
  }
  cout << sum << endl;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++)
      if (par.find(findpar(dsu, i * m + j)) != par.end())
        cout << '*';
      else
        cout << grid[i][j];
    cout << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  t = 1;
  while (t--) {
    solve();
  }
}
