#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000, 102400000")
#pragma GCC optimize("O2")
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double PI = 3.14159265358979323846;
const int maxn = 50 + 10;
const int maxnn = 1e5 + 100;
typedef struct {
  int x, y, num;
} lk;
lk lake[maxnn];
int vis[maxn][maxn];
int dir[4][2] = {1, 0, -1, 0, 0, 1, 0, -1};
char a[maxn][maxn];
int n, m, k;
int num, cnt, flag, ans;
void dfs(int r, int l) {
  int rr, ll, i;
  vis[r][l] = 1;
  num++;
  for (i = 0; i < 4; ++i) {
    rr = r + dir[i][0];
    ll = l + dir[i][1];
    if (!vis[rr][ll] && a[rr][ll] == '.' && rr >= 0 && rr < n && ll >= 0 &&
        ll < m) {
      if (rr == 0 || rr == n - 1 || ll == 0 || ll == m - 1) flag = 1;
      dfs(rr, ll);
    }
  }
}
void fillup(int r, int l) {
  int rr, ll, i;
  a[r][l] = '*';
  for (i = 0; i < 4; ++i) {
    rr = r + dir[i][0];
    ll = l + dir[i][1];
    if (a[rr][ll] == '.' && rr >= 0 && rr < n && ll >= 0 && ll < m)
      fillup(rr, ll);
  }
}
int cmp(const lk& a, const lk& b) { return a.num < b.num; }
int main() {
  int i, j;
  scanf("%d%d%d", &n, &m, &k);
  for (i = 0; i < n; ++i) scanf("%s", a[i]);
  cnt = 0;
  for (i = 0; i < n; ++i) {
    for (j = 0; j < m; ++j) {
      if (a[i][j] == '.' && !vis[i][j] && i && j && i != n - 1 && j != m - 1) {
        num = flag = 0;
        dfs(i, j);
        if (!flag) lake[cnt].x = i, lake[cnt].y = j, lake[cnt].num = num, cnt++;
      }
    }
  }
  sort(lake, lake + cnt, cmp);
  ans = 0;
  for (i = 0; i < cnt - k; ++i) {
    fillup(lake[i].x, lake[i].y);
    ans += lake[i].num;
  }
  printf("%d\n", ans);
  for (i = 0; i < n; ++i) printf("%s\n", a[i]);
  return 0;
}
