#include <bits/stdc++.h>
using namespace std;
int n, m;
bool in(int x, int y) {
  if (x >= 1 && x <= n && y >= 1 && y <= m) return 1;
  return 0;
}
bool u[55][55];
int d[55][55], cnt;
char a[55][55];
pair<int, int> p[3000];
void dfs(int x, int y) {
  u[x][y] = 1;
  ++p[cnt].first;
  d[x][y] = cnt;
  for (int i = -1; i <= 1; ++i) {
    for (int j = -1; j <= 1; ++j) {
      if (abs(i) + abs(j) == 1 && in(i + x, y + j) && a[i + x][j + y] == '.' &&
          !u[i + x][y + j]) {
        dfs(x + i, y + j);
      }
    }
  }
}
void dfs2(int x, int y) {
  u[x][y] = 1;
  for (int i = -1; i <= 1; ++i) {
    for (int j = -1; j <= 1; ++j) {
      if (abs(i) + abs(j) == 1 && in(i + x, y + j) && a[i + x][j + y] == '.' &&
          !u[i + x][y + j]) {
        dfs(x + i, y + j);
      }
    }
  }
}
int k, ans;
set<int> st;
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      cin >> a[i][j];
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (!u[i][m] && a[i][m] == '.') dfs2(i, m);
    if (!u[i][1] && a[i][1] == '.') dfs2(i, 1);
  }
  for (int i = 1; i <= m; ++i) {
    if (!u[n][i] && a[n][i] == '.') dfs2(n, i);
    if (!u[1][i] && a[1][i] == '.') dfs2(1, i);
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (a[i][j] == '.' && !u[i][j]) {
        ++cnt;
        p[cnt].second = cnt;
        dfs(i, j);
      }
    }
  }
  sort(p + 1, p + cnt + 1);
  for (int i = 1; i <= cnt - k; ++i) {
    ans += p[i].first;
    st.insert(p[i].second);
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (st.find(d[i][j]) != st.end()) {
        a[i][j] = '*';
      }
    }
  }
  cout << ans << "\n";
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      cout << a[i][j];
    }
    cout << endl;
  }
  return 0;
}
