#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
const double eps = 1e-8;
const long long linf = 1e18;
const int MAXN = 2e3 + 10;
const int MAXM = MAXN << 1;
char s[55][55];
bool vis[55][55];
int n, m;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
bool flags;
struct node {
  int x, y, num;
  node(int a = 0, int b = 0, int c = 0) : x(a), y(b), num(c) {}
  bool operator<(const node& a) const { return num < a.num; }
} a[55 * 55];
;
bool judge(int x, int y) {
  if (x < 0 || x >= n || y < 0 || y >= m || s[x][y] != '.' || vis[x][y])
    return 0;
  return 1;
}
bool judge1(int x, int y) {
  if (x < 0 || x >= n || y < 0 || y >= m || s[x][y] != '.') return 0;
  return 1;
}
int dfs(int x, int y) {
  if (x == 0 || y == 0 || x == n - 1 || y == m - 1) {
    flags = 0;
    return 0;
  }
  vis[x][y] = 1;
  int ans = 1;
  for (int i = 0; i < 4; ++i) {
    int nx = dx[i] + x;
    int ny = dy[i] + y;
    if (judge(nx, ny)) {
      ans += dfs(nx, ny);
    }
  }
  return ans;
}
void dfs1(int x, int y) {
  s[x][y] = '*';
  for (int i = 0; i < 4; ++i) {
    int nx = dx[i] + x;
    int ny = dy[i] + y;
    if (judge1(nx, ny)) dfs1(nx, ny);
  }
}
int main() {
  int k;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < n; ++i) scanf("%s", s[i]);
  int p = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (s[i][j] == '.' && !vis[i][j]) {
        flags = 1;
        int flag = dfs(i, j);
        if (flags) a[p++] = node(i, j, flag);
      }
    }
  }
  int ans = 0;
  sort(a, a + p);
  for (int i = 0; i < p - k; ++i) {
    ans += a[i].num;
    dfs1(a[i].x, a[i].y);
  }
  printf("%d\n", ans);
  for (int i = 0; i < n; ++i) puts(s[i]);
  return 0;
}
