#include <bits/stdc++.h>
using namespace std;
int n, m;
char a[60][60], b[60][60];
int dir[4][2] = {0, 1, 1, 0, -1, 0, 0, -1};
struct node {
  int x, y, sum;
};
node ans[2600];
bool cmp(node a, node b) { return a.sum < b.sum; }
int bfs(int x, int y) {
  queue<node> q;
  node t, next;
  t.x = x;
  t.y = y;
  q.push(t);
  int cnt = 1;
  a[x][y] = '*';
  while (!q.empty()) {
    t = q.front();
    q.pop();
    for (int i = 0; i < 4; i++) {
      int tx = t.x + dir[i][0];
      int ty = t.y + dir[i][1];
      if (tx < 0 || ty < 0 || tx >= n || ty >= m) {
        cnt = -1e9;
        continue;
      }
      if (a[tx][ty] == '*') continue;
      a[tx][ty] = '*';
      next.x = tx;
      next.y = ty;
      cnt++;
      q.push(next);
    }
  }
  return cnt;
}
void bfs2(int x, int y) {
  queue<node> q;
  node t, next;
  t.x = x;
  t.y = y;
  q.push(t);
  b[x][y] = '*';
  while (!q.empty()) {
    t = q.front();
    q.pop();
    for (int i = 0; i < 4; i++) {
      int tx = t.x + dir[i][0];
      int ty = t.y + dir[i][1];
      if (b[tx][ty] == '*') continue;
      b[tx][ty] = '*';
      next.x = tx;
      next.y = ty;
      q.push(next);
    }
  }
}
int main(void) {
  int i, j, k;
  while (scanf("%d%d%d", &n, &m, &k) == 3) {
    for (i = 0; i < n; i++) {
      scanf("%s", a[i]);
      strcpy(b[i], a[i]);
    }
    int c = 0;
    for (i = 0; i < n; i++)
      for (j = 0; j < m; j++)
        if (a[i][j] == '.') {
          int t = bfs(i, j);
          if (t > 0) {
            ans[c].x = i;
            ans[c].y = j;
            ans[c].sum = t;
            c++;
          }
        }
    sort(ans, ans + c, cmp);
    int sum = 0;
    for (i = 0; i < c - k; i++) {
      sum += ans[i].sum;
      bfs2(ans[i].x, ans[i].y);
    }
    printf("%d\n", sum);
    for (i = 0; i < n; i++) printf("%s\n", b[i]);
  }
}
