#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> v;
vector<vector<pair<int, int>>> vec;
char grid[55][55];
bool vis[55][55];
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
int n, m, k, ans = 0;
void flood1(int i, int j) {
  if (i < 0 || i >= n || j < 0 || j >= m) return;
  if (grid[i][j] == '*' || vis[i][j]) return;
  if (grid[i][j] == '.' && !vis[i][j]) {
    vis[i][j] = 1;
    for (int r = 0; r < 4; r++) {
      flood1(i + dx[r], j + dy[r]);
    }
  }
}
void flood2(int i, int j) {
  v.push_back(make_pair(i, j));
  vis[i][j] = 1;
  for (int r = 0; r < 4; r++) {
    int x = i + dx[r];
    int y = j + dy[r];
    if (grid[x][y] == '.' && !vis[x][y]) flood2(x, y);
  }
}
bool comp(vector<pair<int, int>> v1, vector<pair<int, int>> v2) {
  return v1.size() < v2.size();
}
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> grid[i][j];
    }
  }
  for (int i = 0; i < m; i++)
    if (grid[0][i] == '.' && !vis[0][i]) flood1(0, i);
  for (int i = 0; i < n; i++)
    if (grid[i][0] == '.' && !vis[i][0]) flood1(i, 0);
  for (int i = 0; i < m; i++)
    if (grid[n - 1][i] == '.' && !vis[n - 1][i]) flood1(n - 1, i);
  for (int i = 0; i < n; i++)
    if (grid[i][m - 1] == '.' && !vis[i][m - 1]) flood1(i, m - 1);
  for (int i = 1; i < n - 1; i++) {
    for (int j = 1; j < m - 1; j++) {
      if (grid[i][j] == '.' && !vis[i][j]) {
        flood2(i, j);
        vec.push_back(v);
        v.clear();
      }
    }
  }
  sort(vec.begin(), vec.end(), comp);
  k = vec.size() - k;
  for (int i = 0; i < k; i++) {
    ans += vec[i].size();
    for (pair<int, int> p : vec[i]) grid[p.first][p.second] = '*';
  }
  cout << ans << endl;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cout << grid[i][j];
    }
    cout << endl;
  }
  return 0;
}
