#include <bits/stdc++.h>
using namespace std;
char s[55][55];
int n, m, k, adj, cnt, tot;
int vis[55][55];
int dx[] = {-1, 1, 0, 0}, dy[] = {0, 0, -1, 1};
int f[55 * 55];
vector<pair<int, int> > v;
void dfs(int x, int y) {
  cnt++;
  vis[x][y] = tot;
  if (x == 0 || x == n - 1 || y == 0 || y == m - 1) adj = 1;
  for (int i = 0; i < 4; i++) {
    int nx = x + dx[i], ny = y + dy[i];
    if (nx < 0 || nx >= n || ny < 0 || ny >= m || s[nx][ny] != '.' ||
        vis[nx][ny])
      continue;
    dfs(nx, ny);
  }
}
int main() {
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 0; i < n; i++) scanf("%s", s[i]);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (s[i][j] == '.' && !vis[i][j]) {
        cnt = adj = 0;
        ++tot;
        dfs(i, j);
        if (!adj) v.push_back({cnt, tot});
      }
    }
  sort(v.begin(), v.end());
  int sum = 0;
  for (int i = v.size(), j = 0; i > k; i--, j++) {
    f[v[j].second] = 1;
    sum += v[j].first;
  }
  cout << sum << endl;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (f[vis[i][j]])
        putchar('*');
      else
        putchar(s[i][j]);
    }
    puts("");
  }
  return 0;
}
