#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<vector<int>> a(n, vector<int>(m));
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < m; j++) {
      if (s[j] == '.') a[i][j] = 1;
    }
  }
  vector<vector<int>> v(n, vector<int>(m));
  vector<pair<int, pair<int, int>>> an;
  for (int i = 1; i < n - 1; i++) {
    for (int j = 1; j < m - 1; j++) {
      if (a[i][j] == 0 || v[i][j] == 1) continue;
      v[i][j] = 1;
      queue<pair<int, int>> q;
      q.push({i, j});
      int fl = 0, c = 1;
      while (!q.empty()) {
        pair<int, int> pa = q.front();
        q.pop();
        int x = pa.first, y = pa.second;
        if (x - 1 >= 0 && a[x - 1][y] == 1 && v[x - 1][y] == 0) {
          if (x - 1 == 0) fl = 1;
          v[x - 1][y] = 1;
          q.push({x - 1, y});
          c++;
        }
        if (y - 1 >= 0 && a[x][y - 1] == 1 && v[x][y - 1] == 0) {
          if (y - 1 == 0) fl = 1;
          v[x][y - 1] = 1;
          q.push({x, y - 1});
          c++;
        }
        if (x + 1 < n && a[x + 1][y] == 1 && v[x + 1][y] == 0) {
          if (x + 1 == n - 1) fl = 1;
          v[x + 1][y] = 1;
          q.push({x + 1, y});
          c++;
        }
        if (y + 1 < m && a[x][y + 1] == 1 && v[x][y + 1] == 0) {
          if (y + 1 == m - 1) fl = 1;
          v[x][y + 1] = 1;
          q.push({x, y + 1});
          c++;
        }
      }
      if (fl == 0) an.push_back({c, {i, j}});
    }
  }
  sort(an.begin(), an.end());
  int ans = 0;
  for (int i = 0; i < an.size() - k; i++) {
    ans += an[i].first;
    int xx = an[i].second.first, yy = an[i].second.second;
    a[xx][yy] = 0;
    queue<pair<int, int>> q;
    q.push({xx, yy});
    while (!q.empty()) {
      pair<int, int> pa = q.front();
      q.pop();
      int x = pa.first, y = pa.second;
      if (x - 1 >= 0 && a[x - 1][y] == 1) {
        q.push({x - 1, y});
        a[x - 1][y] = 0;
      }
      if (y - 1 >= 0 && a[x][y - 1] == 1) {
        q.push({x, y - 1});
        a[x][y - 1] = 0;
      }
      if (x + 1 < n && a[x + 1][y] == 1) {
        a[x + 1][y] = 0;
        q.push({x + 1, y});
      }
      if (y + 1 < m && a[x][y + 1] == 1) {
        a[x][y + 1] = 0;
        q.push({x, y + 1});
      }
    }
  }
  cout << ans << endl;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++)
      if (a[i][j] == 1)
        cout << '.';
      else
        cout << '*';
    cout << endl;
  }
  return 0;
}
