#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:10034217728")
using namespace std;
const int N = 60;
string t[N];
int r, c, k;
vector<vector<pair<int, int>>> ls;
vector<pair<int, int>> cur;
bool was[N][N];
int dx[] = {0, 0, -1, 1};
int dy[] = {-1, 1, 0, 0};
bool oceanus = 0;
void dfs(pair<int, int> v) {
  cur.push_back(v);
  was[v.first][v.second] = 1;
  for (int k = 0; k < 4; k++) {
    pair<int, int> nxt = make_pair(dx[k] + v.first, v.second + dy[k]);
    if (nxt.first < 0 || nxt.second < 0 || nxt.first >= r || nxt.second >= c) {
      oceanus = 1;
      continue;
    }
    if (was[nxt.first][nxt.second]) continue;
    if (t[nxt.first][nxt.second] == '*') continue;
    dfs(nxt);
  }
}
bool cmp(const vector<pair<int, int>>& a, const vector<pair<int, int>>& b) {
  return a.size() > b.size();
}
int main() {
  cin >> r >> c >> k;
  for (int i = 0; i < r; i++) cin >> t[i];
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      if (was[i][j]) continue;
      if (t[i][j] == '*') continue;
      cur.clear();
      oceanus = 0;
      dfs(make_pair(i, j));
      if (!oceanus) ls.push_back(cur);
    }
  }
  sort(ls.begin(), ls.end(), cmp);
  int u = 0;
  while (ls.size() != k) {
    auto& g = ls.back();
    for (auto el : g) {
      u++;
      t[el.first][el.second] = '*';
    }
    ls.pop_back();
  }
  cout << u << endl;
  for (int i = 0; i < r; i++) cout << t[i] << endl;
  return 0;
}
