#include <bits/stdc++.h>
using namespace std;
int n, m, k, vis[55][55], ans, flag;
int fx[4] = {0, 0, 1, -1}, fy[4] = {1, -1, 0, 0};
char mapp[55][55];
struct node {
  int step;
  int xi, yi;
} num[55 * 55];
bool cmp(node a, node b) { return a.step < b.step; }
void dfs(int x, int y) {
  vis[x][y] = 1;
  if ((x == 0 || x == n - 1 || y == 0 || y == m - 1) && mapp[x][y] == '.')
    flag = 1;
  for (int i = 0; i < 4; i++) {
    int nx = x + fx[i];
    int ny = y + fy[i];
    if ((nx == 0 || nx == n - 1 || ny == 0 || ny == m - 1) &&
        mapp[nx][ny] == '.')
      flag = 1;
    if (nx >= 0 && nx < n && ny >= 0 && ny < m && !vis[nx][ny] &&
        mapp[nx][ny] == '.') {
      num[ans].step++;
      dfs(nx, ny);
    }
  }
}
void formMap(int x, int y) {
  vis[x][y] = 1;
  mapp[x][y] = '*';
  for (int i = 0; i < 4; i++) {
    int nx = x + fx[i];
    int ny = y + fy[i];
    if (nx >= 0 && nx < n && ny >= 0 && ny < m && !vis[nx][ny] &&
        mapp[nx][ny] == '.') {
      formMap(nx, ny);
    }
  }
}
int main() {
  while (cin >> n >> m >> k) {
    getchar();
    ans = 0;
    flag = 0;
    memset(vis, 0, sizeof(vis));
    for (int i = 0; i < n; i++) cin >> mapp[i];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (mapp[i][j] == '.' && !vis[i][j]) {
          ans++;
          num[ans].step = 1;
          num[ans].xi = i;
          num[ans].yi = j;
          dfs(i, j);
        }
        if (flag) {
          ans--;
          flag = 0;
        }
      }
    }
    int temp = 0;
    sort(num + 1, num + ans + 1, cmp);
    memset(vis, 0, sizeof(vis));
    for (int i = 1; i <= ans - k; i++) {
      temp += num[i].step;
      formMap(num[i].xi, num[i].yi);
    }
    cout << temp << endl;
    for (int i = 0; i < n; i++) cout << mapp[i] << endl;
  }
  return 0;
}
