#include <bits/stdc++.h>
using namespace std;
const long long N = 1e9 + 7;
char arr[51][51];
long long vis[51][51];
long long flag;
long long n, m, k;
long long dx[] = {0, 0, 1, -1};
long long dy[] = {1, -1, 0, 0};
long long isValid(long long x, long long y) {
  if (x < 0 || y < 0 || x >= n || y >= m || vis[x][y] != 0 || arr[x][y] == '*')
    return 0;
  return 1;
}
long long sc;
void dfs(long long x, long long y, long long cnt) {
  vis[x][y] = cnt;
  sc++;
  if (x == 0 || y == 0 || x == n - 1 || y == m - 1) flag = 1;
  for (long long i = 0; i < 4; i++) {
    long long nx = x + dx[i];
    long long ny = y + dy[i];
    if (isValid(nx, ny)) {
      dfs(nx, ny, cnt);
    }
  }
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m >> k;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) cin >> arr[i][j], vis[i][j] = 0;
  }
  long long x = 1;
  vector<pair<long long, long long>> v;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      if (vis[i][j] == 0 && arr[i][j] == '.') {
        flag = 0;
        sc = 0;
        dfs(i, j, x);
        if (flag == 0) v.push_back({sc, x});
        x = x + 1;
      }
    }
  }
  sort(v.begin(), v.end());
  long long ans = 0;
  long long ff = v.size();
  ff = ff - k;
  for (long long i = 0; i < ff; i++) {
    long long key = v[i].second;
    ans = ans + v[i].first;
    for (long long l = 0; l < n; l++) {
      for (long long j = 0; j < m; j++) {
        if (vis[l][j] == key) arr[l][j] = '*';
      }
    }
  }
  cout << ans << "\n";
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) cout << arr[i][j];
    cout << "\n";
  }
}
