#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using lld = long double;
using l64 = int64_t;
const ll oo = 1e15;
const ll MOD = 1000000007;
const int N = 100;
string ss[N];
int n, m, k;
bool vis[N][N];
int dx[4] = {0, 0, -1, 1};
int dy[4] = {-1, 1, 0, 0};
void bfs(int sx, int sy) {
  queue<pair<int, int> > q;
  q.push({sx, sy});
  vis[sx][sy] = 1;
  while (!q.empty()) {
    const pair<int, int> &p = q.front();
    q.pop();
    for (int i = 0; i < 4; i++) {
      int x = p.first + dx[i];
      int y = p.second + dy[i];
      if (x >= 0 && y >= 0 && x < n && y < m && !vis[x][y] && ss[x][y] == '.') {
        q.push({x, y});
        vis[x][y] = 1;
      }
    }
  }
  return;
}
void collect(int sx, int sy, vector<pair<int, int> > &ar) {
  queue<pair<int, int> > q;
  q.push({sx, sy});
  vis[sx][sy] = 1;
  while (!q.empty()) {
    const auto &p = q.front();
    ar.emplace_back(p.first, p.second);
    q.pop();
    for (int i = 0; i < 4; i++) {
      int x = p.first + dx[i];
      int y = p.second + dy[i];
      if (x >= 0 && y >= 0 && x < n && y < m && !vis[x][y] && ss[x][y] == '.') {
        q.push({x, y});
        vis[x][y] = 1;
      }
    }
  }
  return;
}
vector<vector<pair<int, int> > > ans;
vector<pair<int, int> > tmp;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) cin >> ss[i];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (i == 0 || i == n - 1) {
        if (ss[i][j] == '.') bfs(i, j);
      }
      if (j == 0 || j == m - 1) {
        if (ss[i][j] == '.') bfs(i, j);
      }
    }
  }
  for (int i = 1; i < n; i++)
    for (int j = 1; j < m; j++) {
      if (ss[i][j] == '.' and !vis[i][j]) {
        tmp.clear();
        collect(i, j, tmp);
        ans.push_back(tmp);
      }
    }
  sort(ans.begin(), ans.end(),
       [&](const vector<pair<int, int> > &a, const vector<pair<int, int> > &b) {
         return a.size() > b.size();
       });
  int i = 0;
  while (i < k) i++;
  int cnt = 0;
  while (i < ans.size()) {
    for (auto p : ans[i]) ss[p.first][p.second] = '*', cnt++;
    i++;
  }
  cout << cnt << "\n";
  for (int i = 0; i < n; i++) cout << ss[i] << "\n";
  return 0;
}
