#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int a[55][55], ch[55][55], te[55][55];
int p[4] = {1, -1, 0, 0};
int q[4] = {0, 0, 1, -1};
int cnt, res, t;
vector<pair<int, int> > r;
void dfs(int x, int y) {
  ch[x][y] = 1;
  cnt++;
  te[x][y] = t;
  if (x == 1 || x == n || y == 1 || y == m) res = 1;
  for (int i = 0; i < 4; i++) {
    if (x + p[i] >= 1 && x + p[i] <= n && y + q[i] >= 1 && y + q[i] <= m &&
        a[x + p[i]][y + q[i]] == 1 && ch[x + p[i]][y + q[i]] == 0) {
      dfs(x + p[i], y + q[i]);
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    s = ' ' + s;
    for (int j = 1; j <= m; j++) {
      if (s[j] == '.')
        a[i][j] = 1;
      else
        a[i][j] = 0;
      ch[i][j] = 0;
    }
  }
  t = 0;
  for (int i = 2; i < n; i++) {
    for (int j = 2; j < m; j++) {
      if (a[i][j] == 1 && ch[i][j] == 0) {
        cnt = 0;
        res = 0;
        t++;
        dfs(i, j);
        if (res == 0) r.push_back(pair<int, int>(cnt, t));
      }
    }
  }
  sort(r.begin(), r.end());
  int ans = 0;
  for (int i = 0; i < r.size() - k; i++) {
    ans += r[i].first;
    for (int j = 1; j <= n; j++)
      for (int h = 1; h <= m; h++)
        if (te[j][h] == r[i].second) a[j][h] = 0;
  }
  cout << ans << endl;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (a[i][j] == 0)
        cout << "*";
      else
        cout << ".";
    }
    cout << endl;
  }
  return 0;
}
