#include <bits/stdc++.h>
using namespace std;
const int maxn = 50 + 7;
const int INF = 0x3f3f3f3f;
int n, m, k;
char s[maxn][maxn];
int f[maxn][maxn] = {0};
int id = 1, cnt;
bool ok;
vector<pair<int, int> > vec;
int dx[5] = {0, 0, 1, -1};
int dy[5] = {1, -1, 0, 0};
void dfs(int x, int y) {
  if (x == 1 || x == n || y == 1 || y == m) ok = false;
  cnt++;
  f[x][y] = id;
  for (int i = 0; i < 4; ++i) {
    int nx = x + dx[i], ny = y + dy[i];
    if (nx >= 1 && nx <= n && ny >= 1 && ny <= m && s[nx][ny] != '*' &&
        !f[nx][ny]) {
      dfs(nx, ny);
    }
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%s", s[i] + 1);
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (f[i][j]) continue;
      if (s[i][j] == '*') continue;
      ok = true;
      cnt = 0;
      dfs(i, j);
      if (ok) vec.push_back(pair<int, int>(cnt, id));
      id++;
    }
  }
  sort(vec.begin(), vec.end());
  int t = (int)vec.size() - k;
  int ans = 0;
  for (int i_ = 0; i_ < t; ++i_) {
    ans += vec[i_].first;
    int t = vec[i_].second;
    for (int i = 1; i <= n; ++i) {
      for (int j = 1; j <= m; ++j) {
        if (f[i][j] == t) f[i][j] = -1;
      }
    }
  }
  printf("%d\n", ans);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (f[i][j] == -1)
        printf("*");
      else
        printf("%c", s[i][j]);
    }
    puts("");
  }
  return 0;
}
