#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LLINF = 0x3f3f3f3f3f3f3f3f;
struct lt {
  int x, y, c;
  bool operator<(lt a) const { return c < a.c; }
};
char dt[60][60];
bool pd[60][60];
bool vis[60][60];
int n, m, k;
int dfs(int x, int y) {
  if ((x <= 0 || x >= n - 1 || y <= 0 || y >= m - 1) && dt[x][y] == '.')
    return -1;
  if (dt[x][y] != '.' || pd[x][y]) return 0;
  int ans = 1;
  int temp;
  pd[x][y] = true;
  vis[x][y] = true;
  temp = dfs(x, y - 1);
  if (temp == -1) return -1;
  ans += temp;
  temp = dfs(x, y + 1);
  if (temp == -1) return -1;
  ans += temp;
  temp = dfs(x - 1, y);
  if (temp == -1) return -1;
  ans += temp;
  temp = dfs(x + 1, y);
  if (temp == -1) return -1;
  ans += temp;
  return ans;
}
int ans;
void haha(int x, int y) {
  if (dt[x][y] != '.') return;
  ++ans;
  dt[x][y] = '*';
  haha(x, y - 1);
  haha(x, y + 1);
  haha(x - 1, y);
  haha(x + 1, y);
}
lt ri[30000];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < n; ++i) scanf("%s", &dt[i]);
  int len = 0;
  for (int i = 1; i < n - 1; ++i)
    for (int j = 1; j < m - 1; ++j) {
      memset(pd, 0, sizeof(pd));
      if (dt[i][j] == '.' && !vis[i][j]) {
        lt a;
        a.x = i;
        a.y = j;
        a.c = dfs(i, j);
        if (a.c > 0) ri[len++] = a;
      }
    }
  ans = 0;
  sort(ri, ri + len);
  for (int i = 0; i < len - k; ++i) haha(ri[i].x, ri[i].y);
  printf("%d\n", ans);
  for (int i = 0; i < n; ++i) printf("%s\n", dt[i]);
  return 0;
}
