#include <bits/stdc++.h>
using namespace std;
inline int getint() {
  int res = 0;
  char c = getchar();
  bool mi = false;
  while (c < '0' || c > '9') mi = (c == '-'), c = getchar();
  while ('0' <= c && c <= '9') res = res * 10 + c - '0', c = getchar();
  return mi ? -res : res;
}
inline long long int getll() {
  long long int res = 0;
  char c = getchar();
  bool mi = false;
  while (c < '0' || c > '9') mi = (c == '-'), c = getchar();
  while ('0' <= c && c <= '9') res = res * 10 + c - '0', c = getchar();
  return mi ? -res : res;
}
int n, m, k;
char M[105][105];
bool used[105][105];
int FloodFill(int x, int y) {
  int cnt = 0;
  bool noanswer = false;
  queue<pair<int, int> > q;
  q.push(pair<int, int>(x, y));
  while (!q.empty()) {
    int cx = q.front().first;
    int cy = q.front().second;
    q.pop();
    if (M[cx][cy] == 0) {
      noanswer = true;
      continue;
    }
    if (used[cx][cy] || M[cx][cy] == '*') continue;
    used[cx][cy] = true;
    cnt++;
    q.push(pair<int, int>(cx - 1, cy));
    q.push(pair<int, int>(cx + 1, cy));
    q.push(pair<int, int>(cx, cy - 1));
    q.push(pair<int, int>(cx, cy + 1));
  }
  if (noanswer) return -1;
  return cnt;
}
void FloodFill2(int x, int y) {
  queue<pair<int, int> > q;
  q.push(pair<int, int>(x, y));
  while (!q.empty()) {
    int cx = q.front().first;
    int cy = q.front().second;
    q.pop();
    if (M[cx][cy] == '*' || M[cx][cy] == 0) continue;
    M[cx][cy] = '*';
    q.push(pair<int, int>(cx - 1, cy));
    q.push(pair<int, int>(cx + 1, cy));
    q.push(pair<int, int>(cx, cy - 1));
    q.push(pair<int, int>(cx, cy + 1));
  }
}
int sp[25050];
int sa[25050][3];
int s;
bool cmp(const int& a, const int& b) { return sa[a][2] < sa[b][2]; }
int main() {
  n = getint();
  m = getint();
  k = getint();
  for (int i = 1; i <= n; i++) scanf("%s", M[i] + 1);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (M[i][j] == '.' && !used[i][j]) {
        int res = FloodFill(i, j);
        if (res != -1) {
          sa[s][0] = i;
          sa[s][1] = j;
          sa[s][2] = res;
          s++;
        }
      }
  for (int i = 0; i < s; i++) sp[i] = i;
  sort(sp, sp + s, cmp);
  int res = 0;
  for (int i = 0; i < s - k; i++) {
    res += sa[sp[i]][2];
    FloodFill2(sa[sp[i]][0], sa[sp[i]][1]);
  }
  printf("%d\n", res);
  for (int i = 1; i <= n; i++) printf("%s\n", M[i] + 1);
  return 0;
}
