#include <bits/stdc++.h>
using namespace std;
const int N = 1e2 + 5;
string grid[N];
bool found, vis[N][N];
;
int n, m, k, cnt, ans;
vector<pair<int, pair<int, int> > > p;
int dr[] = {-1, 1, 0, 0};
int dc[] = {0, 0, -1, 1};
bool check(int r, int c) {
  return r == 0 || r == n - 1 || c == 0 || c == m - 1;
}
bool valid(int r, int c) { return r >= 0 && r < n && c >= 0 && c < m; }
void dfs(int r, int c) {
  vis[r][c] = 1;
  if (check(r, c)) found = 1;
  cnt++;
  for (int i = 0; i < 4; i++) {
    int rr = r + dr[i], cc = c + dc[i];
    if (valid(rr, cc) && !vis[rr][cc] && grid[rr][cc] == '.') dfs(rr, cc);
  }
}
void build(int r, int c) {
  grid[r][c] = '*';
  for (int i = 0; i < 4; i++) {
    int rr = r + dr[i], cc = c + dc[i];
    if (valid(rr, cc)) {
      if (grid[rr][cc] == '.') {
        build(rr, cc);
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) {
    cin >> grid[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (!vis[i][j] && grid[i][j] == '.') {
        found = 0;
        cnt = 0;
        dfs(i, j);
        if (found) continue;
        p.push_back({cnt, {i, j}});
      }
    }
  }
  sort(p.begin(), p.end());
  for (int i = 0; i < (int)p.size() - k; i++) {
    ans += p[i].first;
    build(p[i].second.first, p[i].second.second);
  }
  cout << ans << "\n";
  for (int i = 0; i < n; i++) {
    cout << grid[i] << "\n";
  }
  return 0;
}
