#include <bits/stdc++.h>
using namespace std;
const int dx[5] = {0, 1, -1, 0, 0};
const int dy[5] = {0, 0, 0, 1, -1};
char s[60][60];
int t[60][60];
int M, N, K;
struct thing {
  int x;
  int y;
  int s;
  bool operator<(const thing &th) const { return s < th.s; }
} o[2510];
int A;
void dfs1(int x, int y) {
  if (x < 1 || y < 1 || x > M || y > N) return;
  if (t[x][y] != 1) return;
  t[x][y] = -1;
  for (int i = 1; i <= 4; i++) dfs1(x + dx[i], y + dy[i]);
}
int now;
void dfs2(int x, int y) {
  if (x < 1 || y < 1 || x > M || y > N) return;
  if (t[x][y] != 1) return;
  t[x][y] = 2;
  now++;
  for (int i = 1; i <= 4; i++) dfs2(x + dx[i], y + dy[i]);
}
void dfs3(int x, int y) {
  if (x < 1 || y < 1 || x > M || y > N) return;
  if (t[x][y] != 2) return;
  t[x][y] = 3;
  s[x][y] = '*';
  for (int i = 1; i <= 4; i++) dfs3(x + dx[i], y + dy[i]);
}
int give;
int main() {
  cin >> M >> N >> K;
  for (int i = 1; i <= M; i++)
    for (int j = 1; j <= N; j++) {
      cin >> s[i][j];
      if (s[i][j] == '.') t[i][j] = 1;
    }
  for (int i = 1; i <= M; i++) {
    dfs1(i, 1);
    dfs1(i, N);
  }
  for (int i = 1; i <= N; i++) {
    dfs1(1, i);
    dfs1(M, i);
  }
  for (int i = 1; i <= M; i++)
    for (int j = 1; j <= N; j++) {
      if (t[i][j] == 1) {
        now = 0;
        dfs2(i, j);
        A++;
        o[A].x = i;
        o[A].y = j;
        o[A].s = now;
      }
    }
  sort(o + 1, o + 1 + A);
  for (int i = 1; i <= A - K; i++) {
    give += o[i].s;
    dfs3(o[i].x, o[i].y);
  }
  cout << give << endl;
  for (int i = 1; i <= M; i++) {
    for (int j = 1; j <= N; j++) cout << s[i][j];
    cout << endl;
  }
  return 0;
}
