#include <bits/stdc++.h>
using namespace std;
bool has[2005][2005];
int change[4][2] = {1, 0, 0, 1, -1, 0, 0, -1};
int n, m, k;
char mp[2005][2005];
struct no {
  int num, val;
} lake[2005];
struct node {
  int x, y;
} now, nex;
vector<node> v[2005];
int cot;
bool cmp(no a, no b) { return a.val > b.val; }
bool flag;
int bfs(int x, int y) {
  v[cot].clear();
  queue<node> que;
  has[x][y] = 1;
  now.x = x;
  now.y = y;
  flag = 0;
  if (x == 0 || y == 0 || x == n - 1 || y == m - 1) flag = 1;
  int tol = 1;
  que.push(now);
  v[cot].push_back(now);
  while (!que.empty()) {
    now = que.front();
    que.pop();
    for (int i = 0; i < 4; i++) {
      nex.x = now.x + change[i][0];
      nex.y = now.y + change[i][1];
      if (mp[nex.x][nex.y] == '*' || nex.x < 0 || nex.x >= n || nex.y < 0 ||
          nex.y >= m || has[nex.x][nex.y])
        continue;
      if (nex.x == 0 || nex.y == 0 || nex.x == n - 1 || nex.y == m - 1)
        flag = 1;
      que.push(nex);
      has[nex.x][nex.y] = 1;
      v[cot].push_back(nex);
      tol++;
    }
  }
  return tol;
}
int main() {
  scanf("%d%d", &n, &m);
  scanf("%d", &k);
  for (int i = 0; i < n; i++) scanf("%s", mp[i]);
  cot = 0;
  memset(has, 0, sizeof(has));
  ;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (mp[i][j] == '.' && !has[i][j]) {
        int t = bfs(i, j);
        if (flag) continue;
        lake[cot].val = t;
        lake[cot].num = cot;
        cot++;
      }
    }
  int sum = 0;
  sort(lake, lake + cot, cmp);
  for (int i = k; i < cot; i++) {
    sum += lake[i].val;
    for (int j = 0; j < v[lake[i].num].size(); j++) {
      mp[v[lake[i].num][j].x][v[lake[i].num][j].y] = '*';
    }
  }
  printf("%d\n", sum);
  for (int i = 0; i < n; i++) printf("%s\n", mp[i]);
}
