#include <bits/stdc++.h>
using namespace std;
void __print(long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
void debarr(long long arr[], long long n) {
  cout << "arr : ";
  for (long long i = 0; i <= (n - 1); i++) cout << arr[i] << " ";
  cout << '\n';
}
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  long long f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
const long long mod = 1e9 + 7;
const long long inf = 1e18;
const long long N = 200 + 20;
char mat[N][N];
bool vis[N][N];
long long n, m;
long long comp;
set<pair<long long, long long>> f;
vector<set<pair<long long, long long>>> components;
bool okay(long long r, long long c) {
  if (r >= 1 and r <= n and c >= 1 and c <= m and mat[r][c] == '.') {
    return true;
  }
  return false;
}
void dfs(long long r, long long c) {
  if (vis[r][c]) return;
  vis[r][c] = 1;
  f.insert({r, c});
  if (okay(r + 1, c)) dfs(r + 1, c);
  if (okay(r, c + 1)) dfs(r, c + 1);
  if (okay(r, c - 1)) dfs(r, c - 1);
  if (okay(r - 1, c)) dfs(r - 1, c);
}
bool good(set<pair<long long, long long>> &f) {
  for (auto &it : f) {
    if ((it.first == 1 or it.first == n) or (it.second == 1 or it.second == m))
      return false;
  }
  return true;
}
bool compare(set<pair<long long, long long>> &fi,
             set<pair<long long, long long>> &se) {
  return (fi.size() < se.size());
}
void do_it_nachiket(set<pair<long long, long long>> &nachi) {
  for (auto &it : nachi) mat[it.first][it.second] = '*';
}
long long ans = 0;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m;
  long long k;
  cin >> k;
  for (long long x = 1; x <= n; x++)
    for (long long y = 1; y <= m; y++) cin >> mat[x][y];
  for (long long x = 1; x <= n; x++) {
    for (long long y = 1; y <= m; y++) {
      if (mat[x][y] == '.' and !vis[x][y]) {
        dfs(x, y);
        if (good(f)) components.push_back(f), comp++;
        f.clear();
      }
    }
  }
  sort(components.begin(), components.end(), compare);
  long long to_change = components.size() - k;
  for (long long x = 0; x < to_change; x++) {
    ans += components[x].size();
    do_it_nachiket(components[x]);
  }
  cout << ans << '\n';
  for (long long x = 1; x <= n; x++) {
    for (long long y = 1; y <= m; y++) cout << mat[x][y];
    cout << '\n';
  }
  return 0;
}
