#include <bits/stdc++.h>
using namespace std;
const int MAXN = 110005;
int n, m, ks, fa[MAXN], ans, tot;
char s[55][55];
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
map<int, int> mp;
int hash1(int x, int y) { return (x - 1) * m + y; }
int findf(int x) {
  if (fa[x] == x) return x;
  return fa[x] = findf(fa[x]);
}
void unions(int x, int y) {
  if (findf(x) != findf(y)) {
    fa[findf(x)] = findf(y);
  }
  return;
}
struct hu {
  int root;
  int sum;
} a[MAXN];
bool cmp(hu x, hu y) { return x.sum < y.sum; }
int main() {
  scanf("%d %d %d", &n, &m, &ks);
  n += 2;
  m += 2;
  for (int i = 2; i < n; ++i) {
    scanf("%s", s[i] + 2);
  }
  for (int i = 1; i <= n; ++i) {
    s[i][1] = s[i][m] = '.';
  }
  for (int i = 1; i <= m; ++i) {
    s[1][i] = s[n][i] = '.';
  }
  for (int i = 1; i <= 110000; ++i) {
    fa[i] = i;
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (s[i][j] == '.') {
        for (int k = 0; k < 4; ++k) {
          int new_x = i + dx[k];
          int new_y = j + dy[k];
          if (new_x >= 1 && new_x <= n && new_y >= 1 && new_y <= m) {
            if (s[new_x][new_y] == '.') {
              unions(hash1(i, j), hash1(new_x, new_y));
            }
          }
        }
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (s[i][j] == '.') {
        mp[findf(hash1(i, j))]++;
      }
    }
  }
  for (map<int, int>::iterator it = mp.begin(); it != mp.end(); ++it) {
    a[++tot].root = it->first;
    a[tot].sum = it->second;
  }
  sort(a + 1, a + 1 + tot, cmp);
  tot--;
  for (int p = 1; p <= tot - ks; ++p) {
    for (int i = 1; i <= n; ++i) {
      for (int j = 1; j <= m; ++j) {
        if (findf(hash1(i, j)) == a[p].root) {
          ++ans;
          s[i][j] = '*';
        }
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    s[i][1] = s[i][m] = '\0';
  }
  for (int i = 1; i <= m; ++i) {
    s[1][i] = s[n][i] = '\0';
  }
  printf("%d\n", ans);
  for (int i = 2; i < n; ++i) {
    printf("%s\n", s[i] + 2);
  }
  return 0;
}
