#include <bits/stdc++.h>
using namespace std;
char m[105][105];
int vis[105][105];
int R, C, K;
int mv[] = {-1, 0, 1, 0};
int dfs(int r, int c) {
  vis[r][c] = 1;
  int A = 1, a;
  if (r == R - 1 || r == 0 || c == C - 1 || c == 0) A = 0;
  for (int i = 0; i < 4; i++) {
    int rr = r + mv[i], cc = c + mv[3 - i];
    if (rr > R - 1 || rr < 0 || cc > C - 1 || cc < 0) continue;
    if (m[rr][cc] == '.' && !vis[rr][cc])
      a = dfs(rr, cc), A = A > 0 && a > 0 ? A + a : 0;
  }
  return A;
}
void fill(int r, int c) {
  m[r][c] = '*';
  for (int i = 0; i < 4; i++) {
    int rr = r + mv[i], cc = c + mv[3 - i];
    if (rr > R - 1 || rr < 0 || cc > C - 1 || cc < 0) continue;
    if (m[rr][cc] == '.') fill(rr, cc);
  }
}
int main() {
  while (scanf("%d %d %d", &R, &C, &K) == 3) {
    for (int r = 0; r < R; r++) scanf("%s", m[r]);
    int k = 0, ans = 0;
    vector<pair<int, pair<int, int> > > z;
    for (int r = 0; r < R; r++)
      for (int c = 0; c < C; c++) vis[r][c] = 0;
    for (int r = 0; r < R; r++)
      for (int c = 0; c < C; c++)
        if (!vis[r][c] && m[r][c] == '.') {
          int A = dfs(r, c);
          if (A > 0)
            z.push_back(pair<int, pair<int, int> >(A, pair<int, int>(r, c))),
                k++;
        }
    sort(z.begin(), z.end());
    for (int i = 0; i < k - K; i++)
      ans += z[i].first, fill(z[i].second.first, z[i].second.second);
    printf("%d\n", ans);
    for (int r = 0; r < R; r++) puts(m[r]);
  }
  return 0;
}
