#include <bits/stdc++.h>
using namespace std;
int n, m, k;
char ma[100][100];
bool vis[100][100];
int sz = 0, cnt;
pair<int, int> ne[4] = {make_pair(0, 1), make_pair(1, 0), make_pair(-1, 0),
                        make_pair(0, -1)};
bool f;
vector<pair<int, int>> v;
void dfs(int y, int x) {
  vis[y][x] = 1;
  v.emplace_back(y, x);
  cnt++;
  if (y == 1 || y == n || x == 1 || x == m) {
    f = 0;
  }
  for (int it = 0; it < 4; it++) {
    int i = y + ne[it].first;
    int j = x + ne[it].second;
    if (0 < i && i <= n && 0 < j && j <= m && ma[i][j] == '.' && !vis[i][j])
      dfs(i, j);
  }
}
pair<int, vector<pair<int, int>>> lakes[10000];
inline bool comp(const pair<int, vector<pair<int, int>>> &a,
                 const pair<int, vector<pair<int, int>>> &b) {
  if (a.first < b.first) return 1;
  return 0;
}
int main() {
  int t, i, j, p, q;
  cin >> n >> m >> k;
  for (i = 1; i <= n; i++) scanf("%s", ma[i] + 1);
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      if (ma[i][j] == '.' && !vis[i][j]) {
        f = 1;
        cnt = 0;
        v.clear();
        dfs(i, j);
        if (f) lakes[sz++] = make_pair(cnt, v);
      }
    }
  }
  p = 0;
  sort(lakes, lakes + sz, comp);
  for (i = 0; i < sz; i++) {
    if (sz - i == k) break;
    p += lakes[i].first;
    for (auto x : lakes[i].second) {
      ma[x.first][x.second] = '*';
    }
  }
  printf("%d\n", p);
  for (i = 1; i <= n; i++) printf("%s\n", ma[i] + 1);
  return 0;
}
