#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
const int N = 105;
string second[N];
int vis[N][N];
int dimm, dimn;
int valid(int i, int j) {
  if (0 <= i && i <= dimn && 0 <= j && j <= dimm) {
    if (second[i][j] == '.') return 1;
  }
  return 0;
}
int dfs(int i, int j, int k) {
  if (!valid(i, j)) return 0;
  if (vis[i][j]) return 0;
  vis[i][j] = 1;
  if (k == 1) second[i][j] = '*';
  int ret = 1;
  ret += dfs(i + 1, j, k);
  ret += dfs(i - 1, j, k);
  ret += dfs(i, j + 1, k);
  ret += dfs(i, j - 1, k);
  return ret;
}
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  string tmp = "";
  for (int i = 0; i < m; i++) tmp = tmp + ".";
  for (int i = 1; i <= n; i++) {
    cin >> second[i];
    second[i] = "." + second[i];
    second[i] = second[i] + tmp;
  }
  second[0] = "." + tmp + tmp;
  second[n + 1] = second[0];
  dimn = n + 1;
  dimm = 2 * m;
  int fans = 0;
  int nl = 0;
  for (int i = 0; i <= n + 1; i++) {
    for (int j = 0; j <= 2 * m; j++) {
      if (!vis[i][j] && second[i][j] == '.') {
        nl++;
        int val = dfs(i, j, 0);
      }
    }
  }
  while (k + 1 != nl) {
    int ans = 1000000;
    int ansi, ansj;
    nl = 0;
    memset(vis, 0, sizeof(vis));
    for (int i = 0; i <= n + 1; i++) {
      for (int j = 0; j <= 2 * m; j++) {
        if (!vis[i][j] && second[i][j] == '.') {
          nl++;
          int val = dfs(i, j, 0);
          if (val < n * m && val < ans) {
            ans = val;
            ansi = i;
            ansj = j;
          }
        }
      }
    }
    memset(vis, 0, sizeof(vis));
    fans += ans;
    dfs(ansi, ansj, 1);
    nl--;
  }
  cout << fans << "\n";
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) cout << second[i][j];
    cout << "\n";
  }
  return 0;
}
