#include <bits/stdc++.h>
using namespace std;
int cur = 1, n, m, k;
int visit[100][100] = {0};
queue<pair<int, int> > qu;
string str[100], lakesmap[100];
vector<pair<int, int> > vec[2500], arr;
void findlake(int x, int y) {
  if (visit[x][y] == 1) return;
  visit[x][y] = 1;
  while (!qu.empty()) qu.pop();
  qu.push({x, y});
  while (!qu.empty()) {
    int p = qu.front().first;
    int q = qu.front().second;
    vec[cur].push_back({p, q});
    qu.pop();
    if (p - 1 >= 1 && str[p - 1][q] == '.' && visit[p - 1][q] == 0) {
      qu.push({p - 1, q});
      visit[p - 1][q] = 1;
    }
    if (p + 1 <= n && str[p + 1][q] == '.' && visit[p + 1][q] == 0) {
      qu.push({p + 1, q});
      visit[p + 1][q] = 1;
    }
    if (q - 1 >= 0 && str[p][q - 1] == '.' && visit[p][q - 1] == 0) {
      qu.push({p, q - 1});
      visit[p][q - 1] = 1;
    }
    if (q + 1 < m && str[p][q + 1] == '.' && visit[p][q + 1] == 0) {
      qu.push({p, q + 1});
      visit[p][q + 1] = 1;
    }
  }
  if (!vec[cur].empty()) {
    for (long long i = 0; i <= vec[cur].size() - 1; i++) {
      int p = vec[cur][i].first;
      int q = vec[cur][i].second;
      if (p == 1 || p == n || q == 0 || q == m - 1) {
        vec[cur].clear();
        return;
      }
    }
    for (long long i = 0; i <= vec[cur].size() - 1; i++) {
      int p = vec[cur][i].first;
      int q = vec[cur][i].second;
      str[p][q] = '*';
    }
    cur++;
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> k;
  for (long long i = 1; i <= n; i++) {
    cin >> lakesmap[i];
    str[i] = lakesmap[i];
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 0; j <= m - 1; j++) {
      if (str[i][j] == '.') findlake(i, j);
    }
  }
  arr.clear();
  for (int i = 1; i < cur; i++) {
    arr.push_back({vec[i].size(), i});
  }
  sort(arr.begin(), arr.end());
  int tobefilled = arr.size() - k;
  int ans = 0;
  for (long long i = 0; i <= tobefilled - 1; i++) ans += arr[i].first;
  cout << ans << endl;
  for (long long i = 0; i <= tobefilled - 1; i++) {
    int x = arr[i].second;
    int y = vec[x].size();
    for (long long j = 0; j <= y - 1; j++)
      lakesmap[vec[x][j].first][vec[x][j].second] = '*';
  }
  for (long long i = 1; i <= n; i++) cout << lakesmap[i] << endl;
  return 0;
}
