#include <bits/stdc++.h>
using namespace std;
int a, b, c, cm, cnt, ans;
char m[51][51];
bool was[51][51], rv[51][51];
vector<pair<int, int> > cmp[10000];
map<pair<int, int>, int> pos;
void dfs1(int x, int y) {
  was[x][y] = true;
  cmp[cm].push_back(make_pair(x, y));
  if (!was[x + 1][y] && m[x + 1][y] == '.') dfs1(x + 1, y);
  if (!was[x - 1][y] && m[x - 1][y] == '.') dfs1(x - 1, y);
  if (!was[x][y + 1] && m[x][y + 1] == '.') dfs1(x, y + 1);
  if (!was[x][y - 1] && m[x][y - 1] == '.') dfs1(x, y - 1);
}
void dfs(int x, int y) {
  was[x][y] = true;
  cmp[cm].push_back(make_pair(x, y));
  pos[make_pair(x, y)] = cm;
  if (!was[x + 1][y] && m[x + 1][y] == '.') dfs(x + 1, y);
  if (!was[x - 1][y] && m[x - 1][y] == '.') dfs(x - 1, y);
  if (!was[x][y + 1] && m[x][y + 1] == '.') dfs(x, y + 1);
  if (!was[x][y - 1] && m[x][y - 1] == '.') dfs(x, y - 1);
}
int main() {
  cin >> a >> b >> c;
  for (int i = 1; i <= a; i++)
    for (int j = 1; j <= b; j++) cin >> m[i][j];
  for (int i = 1; i <= a; i++)
    for (int j = 1; j <= b; j++)
      if ((i == 1 || j == 1 || i == a || j == b) && m[i][j] == '.') dfs1(i, j);
  for (int i = 1; i <= a; i++)
    for (int j = 1; j <= b; j++)
      if (!was[i][j] && m[i][j] == '.') cm++, dfs(i, j);
  for (int i = 1; i <= cm; i++)
    for (int j = 1; j <= cm; j++)
      if (cmp[i].size() < cmp[j].size()) swap(cmp[i], cmp[j]);
  for (int i = 1; i <= cm - c; i++) {
    ans += cmp[i].size();
    for (int j = 0; j < cmp[i].size(); j++)
      m[cmp[i][j].first][cmp[i][j].second] = '*';
  }
  cout << ans << endl;
  for (int i = 1; i <= a; i++) {
    for (int j = 1; j <= b; j++) {
      cout << m[i][j];
    }
    cout << endl;
  }
}
