#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
const int mod = 1e9 + 7;
const int MOD = mod - 1;
const double eps = 1e-10;
int n, m, k;
char s[1005][1005];
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
bool v[100][100];
int ans = 0, cnt;
int p = 0;
bool ok;
struct M {
  int x, y, s;
};
M a[N];
int cmp(M a, M b) { return a.s < b.s; }
void dfs(int x, int y) {
  cnt++;
  v[x][y] = 1;
  if (x == 0 || y == 0 || x == n - 1 || y == m - 1) ok = 0;
  for (int i = 0; i < 4; i++) {
    int xx = x + dx[i], yy = y + dy[i];
    if (xx >= 0 && xx < n && yy >= 0 && yy < m && !v[xx][yy] &&
        s[xx][yy] != '*')
      dfs(xx, yy);
  }
}
void tian(int x, int y) {
  s[x][y] = '*';
  for (int i = 0; i < 4; i++) {
    int xx = x + dx[i], yy = y + dy[i];
    if (xx >= 0 && xx < n && yy >= 0 && yy < m && s[xx][yy] != '*')
      tian(xx, yy);
  }
}
int main() {
  scanf("%d", &n), scanf("%d", &m), scanf("%d", &k);
  memset(v, 0, sizeof(v));
  memset(s, 0, sizeof(s));
  for (int i = 0; i < n; i++) {
    scanf("%s", s[i]);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (!v[i][j] && s[i][j] == '.') {
        ok = 1, cnt = 0;
        dfs(i, j);
        if (ok) {
          a[p].x = i, a[p].y = j, a[p].s = cnt;
          p++;
        }
      }
    }
  }
  sort(a, a + p, cmp);
  for (int i = 0; i < p - k; i++) {
    ans += a[i].s;
    tian(a[i].x, a[i].y);
  }
  printf("%d\n", ans);
  for (int i = 0; i < n; i++) puts(s[i]);
  return 0;
}
