#include <bits/stdc++.h>
using namespace std;
int n, m, k;
bool water[55][55];
bool visited[55][55];
vector<pair<int, vector<pair<int, int> > > > result;
bool dfs(int x, int y, int num) {
  visited[x][y] = true;
  result[num].first++;
  result[num].second.push_back({x, y});
  bool result = true;
  if (x != 0)
    if (water[x - 1][y] && !visited[x - 1][y])
      result = result * dfs(x - 1, y, num);
  if (x != n - 1)
    if (water[x + 1][y] && !visited[x + 1][y])
      result = result * dfs(x + 1, y, num);
  if (y != 0)
    if (water[x][y - 1] && !visited[x][y - 1])
      result = result * dfs(x, y - 1, num);
  if (y != m - 1)
    if (water[x][y + 1] && !visited[x][y + 1])
      result = result * dfs(x, y + 1, num);
  if (x == 0 || y == 0 || x == n - 1 || y == m - 1) return false;
  return result;
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      char c;
      scanf(" %c", &c);
      water[i][j] = (c == '.');
    }
  }
  int lastNum = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (water[i][j] && !visited[i][j]) {
        result.push_back({0, vector<pair<int, int> >()});
        if (!dfs(i, j, lastNum))
          result.pop_back();
        else
          lastNum++;
      }
    }
  }
  sort(result.begin(), result.end());
  int ans = 0;
  for (int j = 0; j < result.size() - k; j++) {
    for (int i = 0; i < result[j].first; i++) {
      water[result[j].second[i].first][result[j].second[i].second] = false;
      ans++;
    }
  }
  printf("%d\n", ans);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (water[i][j])
        printf(".");
      else
        printf("*");
    }
    printf("\n");
  }
  return 0;
}
