#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10;
char a[N][N];
int n, m, k, cnt = 0, lakes = 0, delete_zone = 0;
int color[N][N];
int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, -1, 1};
vector<pair<int, int> > lis[N];
bool cmp(vector<pair<int, int> > X, vector<pair<int, int> > Y) {
  return (X.size() < Y.size());
}
bool check(pair<int, int> node) {
  int x = node.first;
  int y = node.second;
  if (x == 1 || x == n || y == 1 || y == m) return false;
  return true;
}
void out() {
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cout << a[i][j];
    }
    cout << "\n";
  }
}
int bfs(int X, int Y, int cnt) {
  color[X][Y] = 1;
  vector<pair<int, int> > nodes;
  int flag = 0;
  pair<int, int> U;
  U.first = X;
  U.second = Y;
  queue<pair<int, int> > q;
  q.push(U);
  while (!q.empty()) {
    pair<int, int> u = q.front();
    if (!check(u)) flag = 1;
    nodes.push_back(u);
    q.pop();
    for (int k = 0; k < 4; k++) {
      int i = u.first + dx[k];
      int j = u.second + dy[k];
      if (a[i][j] == '.' && !color[i][j]) {
        pair<int, int> next;
        next.first = i;
        next.second = j;
        q.push(next);
        color[i][j] = 1;
      }
    }
  }
  if (flag == 0) {
    lis[cnt] = nodes;
    return nodes.size();
  } else {
    return 0;
  }
}
void Delete(vector<pair<int, int> > X) {
  for (int i = 0; i < X.size(); i++) {
    a[X[i].first][X[i].second] = '*';
  }
  return;
}
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (a[i][j] == '.' && !color[i][j]) {
        int temp = bfs(i, j, cnt);
        if (temp != 0) {
          lakes++;
          cnt++;
        }
      }
    }
  }
  sort(lis, lis + cnt, cmp);
  for (int i = 0; i < cnt - k; i++) {
    delete_zone += lis[i].size();
    Delete(lis[i]);
  }
  cout << delete_zone << "\n";
  out();
  return 0;
}
