#include <bits/stdc++.h>
using namespace std;
int n, m, k;
char g[55][55];
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
bool valid(int i, int j) { return i >= 0 && i < n && j >= 0 && j < m; }
void color1(int r, int c) {
  g[r][c] = '#';
  for (int i = 0; i < 4; i++) {
    int nx = dx[i] + r;
    int ny = dy[i] + c;
    if (valid(nx, ny) && g[nx][ny] == '.') {
      g[nx][ny] = '#';
      color1(nx, ny);
    }
  }
}
void color2(int r, int c) {
  g[r][c] = '.';
  for (int i = 0; i < 4; i++) {
    int nx = dx[i] + r;
    int ny = dy[i] + c;
    if (valid(nx, ny) && g[nx][ny] == '#') {
      g[nx][ny] = '.';
      color2(nx, ny);
    }
  }
}
void dfs(int r, int c) {
  g[r][c] = '*';
  for (int i = 0; i < 4; i++) {
    int nx = dx[i] + r;
    int ny = dy[i] + c;
    if (valid(nx, ny) && g[nx][ny] == '.') {
      g[nx][ny] = '*';
      dfs(nx, ny);
    }
  }
}
int cur = 0;
bool vis[55][55];
vector<pair<int, pair<int, int>>> tobe;
void count(int r, int c) {
  vis[r][c] = true;
  cur++;
  for (int i = 0; i < 4; i++) {
    int nx = dx[i] + r;
    int ny = dy[i] + c;
    if (valid(nx, ny) && g[nx][ny] == '.' && vis[nx][ny] == 0) {
      vis[nx][ny] = true;
      count(nx, ny);
    }
  }
}
int main() {
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 0; i < n; i++) scanf(" %s", g[i]);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (i == 0 || j == 0 || i == n - 1 || j == m - 1)
        if (g[i][j] == '.') color1(i, j);
    }
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (g[i][j] == '.' && !vis[i][j]) {
        cnt++;
        cur = 0;
        count(i, j);
        tobe.push_back(make_pair(cur, make_pair(i, j)));
      }
    }
  }
  sort(tobe.begin(), tobe.end());
  int ans = 0;
  int tot = (int)tobe.size() - k;
  for (int i = 0; i < tot; i++) {
    ans += tobe[i].first;
    dfs(tobe[i].second.first, tobe[i].second.second);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (i == 0 || j == 0 || i == n - 1 || j == m - 1)
        if (g[i][j] == '#') color2(i, j);
    }
  }
  printf("%d\n", ans);
  for (int i = 0; i < n; i++) printf("%s\n", g[i]);
  return 0;
}
