#include <bits/stdc++.h>
using namespace std;
const double eps = 0.000000000000001;
string convertstring(long long n) {
  stringstream ss;
  ss << n;
  return ss.str();
}
char s[100][100];
int vis[100][100], n, m;
bool wat(char x) {
  if (x == '.') return true;
  return false;
}
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};
bool isout(int r, int c) {
  if (r >= 1 && r <= n && c >= 1 && c <= m) return false;
  return true;
}
int ff = 0;
int DFS(int r, int c) {
  if (isout(r, c)) ff = 1;
  if (!wat(s[r][c])) return 0;
  vis[r][c] = 1;
  int tot = 1;
  for (int i = 0; i < 4; ++i) {
    if (!vis[r + dx[i]][c + dy[i]]) tot += DFS(r + dx[i], c + dy[i]);
  }
  return tot;
}
void DFS2(int r, int c) {
  if (!wat(s[r][c])) return;
  vis[r][c] = 1;
  s[r][c] = '*';
  for (int i = 0; i < 4; ++i) {
    if (!vis[r + dx[i]][c + dy[i]]) DFS2(r + dx[i], c + dy[i]);
  }
}
vector<pair<int, pair<long long, long long> > > v;
int main() {
  int k, i, j, cc = 1;
  scanf("%d%d%d", &n, &m, &k);
  ;
  for (i = 1; i <= n; ++i) scanf("%s", s[i] + 1);
  for (i = 1; i <= n; ++i) {
    for (j = 1; j <= m; ++j) {
      if (wat(s[i][j]) && vis[i][j] == 0) {
        ff = 0;
        int tot = DFS(i, j);
        if (ff) continue;
        cerr << "tot"
             << " :: " << tot << "\n";
        ;
        v.push_back(make_pair(tot, make_pair(i, j)));
      }
    }
  }
  sort(v.begin(), v.end());
  int x = v.size() - k, ans = 0;
  memset(vis, 0, sizeof(vis));
  ;
  for (i = 0; i < x; ++i) {
    ans += v[i].first;
    int r = v[i].second.first, c = v[i].second.second;
    cerr << "r"
         << " :: " << r << "\t"
         << "c"
         << " :: " << c << "\n";
    ;
    DFS2(r, c);
  }
  printf("%d\n", ans);
  for (i = 1; i <= n; ++i) {
    printf("%s\n", s[i] + 1);
  }
  return 0;
}
