#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
const long long maxn = (long long)60;
const long double EPS = 1e-9;
const long long INF = (long long)1e18 + 18;
const long long mod = (long long)998244353;
long long n, m, k;
char a[maxn][maxn], ini[maxn][maxn];
long long used[maxn][maxn];
map<pair<long long, long long>, vector<pair<long long, long long> > > lakes;
map<pair<long long, long long>, pair<long long, long long> > parent;
pair<long long, long long> get(pair<long long, long long> p) {
  if (parent.count(p) == 0) {
    return p;
  }
  return parent[p] = get(parent[p]);
}
bool merge(pair<long long, long long> p1, pair<long long, long long> p2) {
  p1 = get(p1);
  p2 = get(p2);
  if (p1 != p2) {
    parent[p2] = p1;
    return true;
  }
  return false;
}
bool adjacent(long long x, long long y, long long c, long long d) {
  return (a[x][y] == a[c][d] && a[x][y] == '.');
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string in;
  cin >> n >> m >> k;
  for (long long i = 0; i < n; i++) {
    cin >> in;
    for (long long j = 0; j < m; j++) {
      a[i][j] = in[j];
      ini[i][j] = a[i][j];
    }
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      if (i > 0 && adjacent(i, j, i - 1, j)) {
        merge({i, j}, {i - 1, j});
      }
      if (i < n - 1 && adjacent(i, j, i + 1, j)) {
        merge({i, j}, {i + 1, j});
      }
      if (j > 0 && adjacent(i, j, i, j - 1)) {
        merge({i, j}, {i, j - 1});
      }
      if (j < m - 1 && adjacent(i, j, i, j + 1)) {
        merge({i, j}, {i, j + 1});
      }
    }
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      if (a[i][j] == '.') {
        lakes[get({i, j})].push_back({i, j});
      }
    }
  }
  vector<vector<pair<long long, long long> > > vec;
  for (auto it : lakes) {
    vector<pair<long long, long long> > temp;
    temp.push_back(it.first);
    for (auto p : it.second) {
      temp.push_back(p);
    }
    vec.push_back(temp);
  }
  long long count = 0;
  for (auto& v : vec) {
    bool flag = false;
    for (auto p : v) {
      if (p.first == 0 || p.first == n - 1 || p.second == 0 ||
          p.second == m - 1) {
        flag = true;
      }
      used[p.first][p.second] = 1;
    }
    if (flag) {
      v.clear();
    } else {
      count++;
    }
  }
  sort(vec.begin(), vec.end(),
       [](vector<pair<long long, long long> > left,
          vector<pair<long long, long long> > right) {
         return left.size() > right.size();
       });
  while (vec.size() && vec.back().size() == 0) {
    vec.pop_back();
  }
  for (long long i = 1; i < n - 1; i++) {
    for (long long j = 1; j < m - 1; j++) {
      if (a[i][j] == '.' && used[i][j] == 0) {
        vector<pair<long long, long long> > temp;
        temp.push_back({i, j});
        vec.push_back(temp);
        count++;
      }
    }
  }
  long long rem = count - k;
  for (long long i = vec.size() - 1; i >= 0; i--) {
    if (rem <= 0) break;
    for (auto p : vec[i]) {
      a[p.first][p.second] = '*';
    }
    rem--;
  }
  long long tcnt = 0;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      if (a[i][j] != ini[i][j]) tcnt++;
    }
  }
  cout << tcnt << '\n';
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      cout << a[i][j];
    }
    cout << '\n';
  }
  return 0;
}
