#include <bits/stdc++.h>
using namespace std;
vector<vector<pair<long long int, long long int>>> v2;
vector<pair<long long int, long long int>> v4;
void dfs(long long int r, long long int c, vector<vector<char>> &v1,
         vector<vector<long long int>> &vis, long long int n, long long int m) {
  if (r >= n || r < 0 || c >= m || c < 0 || vis[r][c] == 1) return;
  v4.push_back({r, c});
  vis[r][c] = 1;
  dfs(r + 1, c, v1, vis, n, m);
  dfs(r, c + 1, v1, vis, n, m);
  dfs(r, c - 1, v1, vis, n, m);
  dfs(r - 1, c, v1, vis, n, m);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, m, k1, i, j, cnt;
  cin >> n >> m >> k1;
  vector<vector<char>> v1(n + 1);
  vector<vector<long long int>> vis(n + 1);
  char c;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      cin >> c;
      v1[i].push_back(c);
      if (c == '*')
        vis[i].push_back(1);
      else if (c == '.')
        vis[i].push_back(0);
    }
  }
  long long int f = 0;
  for (i = 1; i < n - 1; i++) {
    for (j = 1; j < m - 1; j++) {
      if (v1[i][j] == '.' && vis[i][j] == 0) {
        v4.clear();
        f = 0;
        dfs(i, j, v1, vis, n, m);
        for (auto l : v4) {
          if (l.first == 0 || l.first == n - 1 || l.second == 0 ||
              l.second == m - 1) {
            f = 1;
            break;
          }
        }
        if (f == 0) v2.push_back(v4);
      }
    }
  }
  vector<pair<long long int, long long int>> v3;
  for (i = 0; i < v2.size(); i++) v3.push_back({v2[i].size(), i});
  sort(v3.begin(), v3.end());
  j = 0;
  long long int l = v2.size();
  long long int h;
  cnt = 0;
  while (k1 != l) {
    for (h = 0; h < v2[v3[j].second].size(); h++) {
      v1[v2[v3[j].second][h].first][v2[v3[j].second][h].second] = '*';
      cnt++;
    }
    j++;
    l--;
  }
  cout << cnt << endl;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) cout << v1[i][j];
    cout << endl;
  }
  return 0;
}
