#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
char g[55][55];
bool vis[55][55];
int res[55][55];
int n, m, k;
inline bool valid(int x, int y) {
  return (x >= 1 && x <= n && y >= 1 && y <= m && g[x][y] == '.');
}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
void dfs(int i, int j, int id) {
  if (vis[i][j] || g[i][j] != '.') return;
  vis[i][j] = 1;
  for (int k = 0; k < 4; k++) {
    int x = i + dx[k], y = j + dy[k];
    if (!valid(x, y)) continue;
    dfs(x, y, id);
  }
  res[i][j] = id;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> g[i][j];
  for (int i = 1; i <= m; i++) dfs(1, i, 0), dfs(n, i, 0);
  for (int i = 1; i <= n; i++) dfs(i, 1, 0), dfs(i, m, 0);
  int id = 1;
  for (int i = 2; i < n; i++)
    for (int j = 2; j < m; j++) {
      if (!vis[i][j] && g[i][j] != '*') dfs(i, j, id++);
    }
  vector<pair<int, int> > cp;
  for (int k = 1; k < id; k++) {
    int c = 0;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) {
        if (res[i][j] == k) c++;
      }
    cp.push_back({c, k});
  }
  sort(cp.begin(), cp.end());
  int x = cp.size(), cnt = 0, ans = 0;
  while (x > k) ans += cp[cnt].first, cnt++, x--;
  for (int k = 0; k < cnt; k++) {
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) {
        if (res[i][j] == cp[k].second) g[i][j] = '*';
      }
  }
  cout << ans << "\n";
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) cout << g[i][j];
    cout << "\n";
  }
  return 0;
}
