#include <bits/stdc++.h>
using namespace std;
char g[64][64];
bool v[64][64];
vector<vector<pair<int, int> > > xx;
bool cmpx(const vector<pair<int, int> >& a, const vector<pair<int, int> >& b) {
  return a.size() < b.size();
}
void dfs(int x, int y) {
  if (x < 0 || y < 0 || x >= 64 || y >= 64) return;
  if (g[x][y] == '.' && !v[x][y]) {
    v[x][y] = true;
    xx.back().push_back(make_pair(x, y));
    dfs(x, y + 1);
    dfs(x, y - 1);
    dfs(x + 1, y);
    dfs(x - 1, y);
  }
}
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  memset(g, '.', sizeof(g));
  memset(v, 0, sizeof(v));
  for (int i = 1; i <= n; ++i) {
    scanf("%s", g[i] + 1);
    g[i][m + 1] = '.';
  }
  xx.push_back(vector<pair<int, int> >());
  dfs(0, 0);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (g[i][j] == '.' && !v[i][j]) {
        xx.push_back(vector<pair<int, int> >());
        dfs(i, j);
      }
    }
  }
  xx.erase(xx.begin());
  sort(xx.begin(), xx.end(), cmpx);
  int r = 0;
  for (int i = 0; i < xx.size() - k; ++i) {
    for (int j = 0; j < xx[i].size(); ++j) {
      g[xx[i][j].first][xx[i][j].second] = '*';
    }
    r += xx[i].size();
  }
  printf("%d\n", r);
  for (int i = 1; i <= n; ++i) {
    g[i][m + 1] = '\0';
    puts(g[i] + 1);
  }
}
