#include <bits/stdc++.h>
using namespace std;
struct A {
  int num, th;
  bool operator<(const A& b) const { return num < b.num; }
};
int n, m, k;
char s[60][60];
int p = 0;
int arr[60 * 60];
int vis[60][60];
vector<pair<int, int>> ans[60 * 60];
vector<A> V;
bool isok = 1;
int cnt;
int walk[4][2] = {{-1, 0}, {0, 1}, {0, -1}, {1, 0}};
bool check(int x, int y) {
  if (x >= 2 && x <= n - 1 && y >= 2 && y <= m - 1) return 1;
  return 0;
}
void dfs(int x, int y) {
  ans[p].push_back(make_pair(x, y));
  vis[x][y] = 1;
  cnt++;
  if (!check(x, y)) {
    isok = 0;
    return;
  }
  for (int i = 0; i < 4; i++) {
    int nx = x + walk[i][0];
    int ny = y + walk[i][1];
    if (s[nx][ny] == '.' && !vis[nx][ny]) dfs(nx, ny);
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) scanf(" %c", &s[i][j]);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      isok = 1, cnt = 0;
      if (s[i][j] == '.' && !vis[i][j]) {
        ans[p].clear();
        dfs(i, j);
        if (isok) {
          arr[p] = cnt;
          V.push_back((A){cnt, p});
          p++;
        } else {
          for (int i = 0; i < ans[p].size(); i++)
            vis[ans[p][i].first][ans[p][i].second] = 0;
        }
      }
    }
  sort(V.begin(), V.end());
  int cntq = 0;
  for (int i = 0; i < p - k; i++) {
    for (int j = 0; j < ans[V[i].th].size(); j++) {
      s[ans[V[i].th][j].first][ans[V[i].th][j].second] = '*', cntq++;
    }
  }
  cout << cntq << endl;
  for (int i = 1; i <= n; i++, puts(""))
    for (int j = 1; j <= m; j++) putchar(s[i][j]);
  return 0;
}
