#include <bits/stdc++.h>
using namespace std;
vector<vector<char> > mat;
int n, m, k, cnt = 0;
vector<vector<bool> > used;
bool flag = 1;
struct str {
  int sz, i, j;
};
vector<pair<int, pair<int, int> > > g;
void dfs(int i, int j) {
  used[i][j] = 1;
  cnt++;
  if (i == 0 || j == 0 || i + 1 == n || j + 1 == m) {
    flag = 0;
  }
  if (i > 0 && mat[i - 1][j] == '.' && !used[i - 1][j]) {
    dfs(i - 1, j);
  }
  if (i + 1 < n && mat[i + 1][j] == '.' && !used[i + 1][j]) {
    dfs(i + 1, j);
  }
  if (j > 0 && mat[i][j - 1] == '.' && !used[i][j - 1]) {
    dfs(i, j - 1);
  }
  if (j + 1 < m && mat[i][j + 1] == '.' && !used[i][j + 1]) {
    dfs(i, j + 1);
  }
}
void dfs_(int i, int j) {
  mat[i][j] = '*';
  used[i][j] = 1;
  if (i > 0 && mat[i - 1][j] == '.' && !used[i - 1][j]) {
    dfs_(i - 1, j);
  }
  if (i + 1 < n && mat[i + 1][j] == '.' && !used[i + 1][j]) {
    dfs_(i + 1, j);
  }
  if (j > 0 && mat[i][j - 1] == '.' && !used[i][j - 1]) {
    dfs_(i, j - 1);
  }
  if (j + 1 < m && mat[i][j + 1] == '.' && !used[i][j + 1]) {
    dfs_(i, j + 1);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> k;
  mat.resize(n, vector<char>(m));
  used.resize(n, vector<bool>(m));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> mat[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (mat[i][j] == '.' && !used[i][j]) {
        cnt = 0;
        flag = 1;
        dfs(i, j);
        if (flag) {
          g.push_back({cnt, {i, j}});
        }
      }
    }
  }
  sort(g.begin(), g.end());
  int pro = (int)g.size(), ans = 0;
  for (auto i : g) {
    if (pro == k) {
      break;
    }
    ans += i.first;
    pro--;
  }
  cout << ans << endl;
  pro = (int)g.size();
  used.clear();
  used.resize(n, vector<bool>(m, 0));
  for (auto i : g) {
    if (pro == k) {
      break;
    }
    dfs_(i.second.first, i.second.second);
    pro--;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cout << mat[i][j];
    }
    cout << endl;
  }
}
