#include <bits/stdc++.h>
using namespace std;
int test_Cases;
long long mod = 1000000007;
long double EPS = 1e-9;
long long int count;
vector<vector<int>> vis;
vector<vector<char>> grid;
vector<pair<pair<long long int, long long int>, long long int>> comp_info;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
long long int compo, n, m, k;
bool booly;
long long int dfs(pair<int, int> nn) {
  if ((nn.first == 0 || nn.first == n - 1 || nn.second == 0 ||
       nn.second == m - 1)) {
    booly = 1;
  }
  vis[nn.first][nn.second] = 1;
  compo++;
  for (int k = 0; k < 4; k++) {
    if (nn.first + dx[k] < n && nn.first + dx[k] >= 0 &&
        nn.second + dy[k] < m && nn.second + dy[k] >= 0 &&
        grid[nn.first + dx[k]][nn.second + dy[k]] == '.' &&
        vis[nn.first + dx[k]][nn.second + dy[k]] == 0) {
      dfs(make_pair(nn.first + dx[k], nn.second + dy[k]));
    }
  }
  if (booly) {
    return mod;
  }
  return compo;
}
void dfs2(pair<int, int> nn) {
  vis[nn.first][nn.second] = 1;
  grid[nn.first][nn.second] = '*';
  for (int k = 0; k < 4; k++) {
    if (nn.first + dx[k] < n && nn.first + dx[k] >= 0 &&
        nn.second + dy[k] < m && nn.second + dy[k] >= 0 &&
        grid[nn.first + dx[k]][nn.second + dy[k]] == '.' &&
        vis[nn.first + dx[k]][nn.second + dy[k]] == 0) {
      dfs2(make_pair(nn.first + dx[k], nn.second + dy[k]));
    }
  }
}
void solve() {
  cin >> n >> m >> k;
  vis = vector<vector<int>>(n + 1, vector<int>(m + 1, 0));
  grid = vector<vector<char>>(n + 1, vector<char>(m + 1));
  for (long long int i = 0; i < (n); ++i) {
    for (long long int j = 0; j < (m); ++j) {
      cin >> grid[i][j];
    }
  }
  long long int mini;
  for (long long int i = 0; i < (n); ++i) {
    for (long long int j = 0; j < (m); ++j) {
      compo = 0;
      booly = 0;
      if (vis[i][j] == 0 && grid[i][j] == '.') {
        long long int count = dfs(make_pair(i, j));
        if (count != mod)
          comp_info.push_back(make_pair(make_pair(count, i), j));
      }
    }
  }
  sort((comp_info).begin(), (comp_info).end());
  vis.clear();
  vis = vector<vector<int>>(n + 1, vector<int>(m + 1, 0));
  long long int ans = 0;
  for (long long int i = 0; i < (comp_info.size() - k); ++i) {
    ans += comp_info[i].first.first;
    dfs2(make_pair(comp_info[i].first.second, comp_info[i].second));
  }
  cout << ans << '\n';
  for (long long int i = 0; i < (n); ++i) {
    for (long long int j = 0; j < (m); ++j) {
      cout << grid[i][j];
    }
    cout << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  test_Cases = 1;
  while (test_Cases--) {
    solve();
  }
  return 0;
}
