#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
int n, mm, k, total;
pair<char, int> m[70][70];
bool invalido;
bool valido(int i, int j) {
  if (i < 0 || j < 0 || i >= n || j >= mm) return false;
  return true;
}
void dfs(int i, int j, int X) {
  for (int l = 0; l < 4; l++) {
    int ii = i + dx[l];
    int jj = j + dy[l];
    if (valido(ii, jj)) {
      if (m[ii][jj].first == '.' and m[ii][jj].second == -1) {
        if (ii == 0 || ii == n - 1 || jj == 0 || jj == mm - 1) {
          invalido = true;
        }
        total++;
        m[ii][jj].second = X;
        dfs(ii, jj, X);
      }
    }
  }
}
void dfs1(pair<int, int> ponto, int X) {
  int i = ponto.first;
  int j = ponto.second;
  for (int l = 0; l < 4; l++) {
    int ii = i + dx[l];
    int jj = j + dy[l];
    if (valido(ii, jj)) {
      if (m[ii][jj].second == X) {
        m[ii][jj].second = -1;
        m[ii][jj].first = '*';
        pair<int, int> pot;
        pot.first = ii;
        pot.second = jj;
        dfs1(pot, X);
      }
    }
  }
}
bool vizinho(int i, int j) {
  bool retorno = true;
  for (int l = 0; l < 4; l++) {
    int ii = i + dx[l];
    int jj = j + dy[l];
    if (m[ii][jj].first == '.') retorno = false;
  }
  return retorno;
}
int main() {
  cin >> n >> mm >> k;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < mm; j++) {
      cin >> m[i][j].first;
      m[i][j].second = -1;
    }
  }
  int X = 0;
  vector<tuple<int, int, pair<int, int> > > v;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < mm; j++) {
      if (m[i][j].first == '.' and m[i][j].second == -1) {
        if (i == 0 || i == n - 1 || j == 0 || j == mm - 1) continue;
        total = 1;
        m[i][j].second = X;
        invalido = false;
        dfs(i, j, X);
        if (invalido == true) continue;
        v.push_back(
            tuple<int, int, pair<int, int> >(total, X, pair<int, int>(i, j)));
        X++;
      }
    }
  }
  int resp = 0;
  if (k < v.size()) {
    sort(v.begin(), v.end());
    for (int l = 0; l < v.size() - k; l++) {
      pair<int, int> ponto;
      int X;
      int lixo;
      tie(lixo, X, ponto) = v[l];
      resp += lixo;
      m[ponto.first][ponto.second].second = -1;
      m[ponto.first][ponto.second].first = '*';
      dfs1(ponto, X);
    }
  } else if (k > v.size()) {
    resp = v.size() - k;
    for (int l = 0; l < k - v.size(); l++) {
      for (int i = 1; i < n - 1; i++) {
        for (int j = 1; j < mm - 1; j++) {
          if (vizinho(i, j)) {
            m[i][j].first = '.';
          }
        }
      }
    }
  }
  cout << resp << endl;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < mm; j++) {
      cout << m[i][j].first;
    }
    cout << endl;
  }
  return 0;
}
