#include <bits/stdc++.h>
using namespace std;
struct arl {
  int val;
  int ind;
};
char a[55][55];
int n, m, k, v[55][55], l[55][55], lake, minlake = 9999999, sum, p[55][55];
arl arr[2505];
void LeeBad(int x, int y) {
  if (x > n || y > m || x < 1 || y < 1) return;
  if (a[x][y] == '*') return;
  if (p[x][y]) return;
  v[x][y] = 1;
  p[x][y] = 1;
  l[x][y] = 0;
  LeeBad(x + 1, y);
  LeeBad(x - 1, y);
  LeeBad(x, y + 1);
  LeeBad(x, y - 1);
}
int Lee(int x, int y, int val, bool init) {
  if (v[x][y]) return 0;
  v[x][y] = 1;
  if (a[x][y] == '*') return 0;
  if (x == n || x == 1 || y == m || y == 1) {
    LeeBad(x, y);
    return 1;
  }
  if (Lee(x + 1, y, val, false) == 1) return 1;
  if (Lee(x - 1, y, val, false) == 1) return 1;
  if (Lee(x, y + 1, val, false) == 1) return 1;
  if (Lee(x, y - 1, val, false) == 1) return 1;
  l[x][y] = lake;
  if (init) lake++;
  return 0;
}
bool comp(arl a, arl b) {
  if (a.val < b.val) return true;
  return false;
}
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
    }
  }
  lake = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      Lee(i, j, lake, true);
    }
  }
  lake--;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (l[i][j] != 0) arr[l[i][j]].val++, arr[l[i][j]].ind = l[i][j];
    }
  }
  sort(arr + 1, arr + lake + 1, comp);
  for (int t = 1; t <= lake - k; t++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        if (l[i][j] == arr[t].ind) a[i][j] = '*', sum++;
      }
    }
  }
  cout << sum << '\n';
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cout << a[i][j];
    }
    cout << '\n';
  }
}
