#include <bits/stdc++.h>
using namespace std;
int f[200][200], c[10500];
int n, m, k, ans, kuai, t = 1;
char s[1001];
struct node {
  int x, id;
} a[15100];
void dfs(int x, int y, int &kuai, int col) {
  kuai++;
  f[x][y] = col;
  if (x > 1 && f[x - 1][y] == 1) dfs(x - 1, y, kuai, col);
  if (y > 1 && f[x][y - 1] == 1) dfs(x, y - 1, kuai, col);
  if (x < n && f[x + 1][y] == 1) dfs(x + 1, y, kuai, col);
  if (y < m && f[x][y + 1] == 1) dfs(x, y + 1, kuai, col);
}
int cmp(node a, node b) { return a.x < b.x; }
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%s", s + 1);
    for (int j = 1; j <= m; j++)
      if (s[j] == '.') f[i][j] = 1;
  }
  for (int i = 1; i <= n; i++) {
    if (f[i][1]) dfs(i, 1, kuai, 10100);
    if (f[i][m]) dfs(i, m, kuai, 10100);
  }
  for (int i = 1; i <= m; i++) {
    if (f[1][i]) dfs(1, i, kuai, 10100);
    if (f[n][i]) dfs(n, i, kuai, 10100);
  }
  for (int i = 2; i <= n; i++)
    for (int j = 2; j <= m; j++)
      if (f[i][j] == 1) {
        kuai = 0;
        ++t;
        dfs(i, j, kuai, t);
        a[t].x = kuai;
        a[t].id = t;
      }
  sort(a + 2, a + t + 1, cmp);
  for (int i = 2; i <= t - k; i++) ans += a[i].x, c[a[i].id] = 1;
  c[0] = 1;
  printf("%d\n", ans);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++)
      if (!c[f[i][j]])
        printf(".");
      else
        printf("*");
    printf("\n");
  }
  return 0;
}
