#include <bits/stdc++.h>
using namespace std;
int cnt = 0, sum = 0;
vector<pair<int, int> > E[100001];
int d[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
int n, m, k;
bool vis[1001][1001];
int top = 0;
pair<int, int> stk[100001];
char str[1001][1001];
bool mark = false;
void dfs(int x, int y) {
  E[cnt].push_back(make_pair(x, y));
  vis[x][y] = true;
  ++sum;
  for (int i = 0; i < 4; i++) {
    int xx = x + d[i][0], yy = y + d[i][1];
    if (xx < 1 || yy < 1 || xx > n || yy > m) {
      mark = true;
      continue;
    }
    if (str[xx][yy] == '*') continue;
    if (vis[xx][yy]) continue;
    dfs(xx, yy);
  }
}
int main() {
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 1; i <= n; i++) scanf("%s", str[i] + 1);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      if (vis[i][j]) continue;
      if (str[i][j] == '*') continue;
      ++cnt;
      sum = 0;
      mark = false;
      dfs(i, j);
      if (mark == false) stk[++top] = make_pair(sum, cnt);
    }
  sort(stk + 1, stk + 1 + top);
  int ans = 0;
  for (int i = 1; i <= top - k; i++) {
    ans += stk[i].first;
    int idx = stk[i].second;
    for (int j = 0; j < (int)E[idx].size(); j++) {
      int x = E[idx][j].first, y = E[idx][j].second;
      str[x][y] = '*';
    }
  }
  printf("%d\n", ans);
  for (int i = 1; i <= n; puts(""), i++)
    for (int j = 1; j <= m; j++) printf("%c", str[i][j]);
  return 0;
}
