#include <bits/stdc++.h>
using namespace std;
class A {
 public:
  int x, y, area = 0;
};
bool cmp(A& a, A& b) { return a.area < b.area; }
A a[3000];
int m[60][60], c, ans, v[60][60];
void dfs1(int x, int y, int n1 = 2) {
  m[x][y] = n1;
  if (m[x + 1][y] == 1) dfs1(x + 1, y, n1);
  if (m[x - 1][y] == 1) dfs1(x - 1, y, n1);
  if (m[x][y + 1] == 1) dfs1(x, y + 1, n1);
  if (m[x][y - 1] == 1) dfs1(x, y - 1, n1);
}
void dfs(int x, int y) {
  a[c].area++;
  v[x][y] = 1;
  if (m[x + 1][y] && !v[x + 1][y]) dfs(x + 1, y);
  if (m[x - 1][y] && !v[x - 1][y]) dfs(x - 1, y);
  if (m[x][y + 1] && !v[x][y + 1]) dfs(x, y + 1);
  if (m[x][y - 1] && !v[x][y - 1]) dfs(x, y - 1);
}
int main() {
  int n, m1, k;
  cin >> n >> m1 >> k;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m1; j++) {
      char c;
      cin >> c;
      if (c == '*') m[i][j] = 0;
      if (c == '.') m[i][j] = 1;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m1; j++) {
      if (m[i][j] == 1 && (i == 1 || i == n || j == 1 || j == m1)) {
        dfs1(i, j);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m1; j++) {
      if (m[i][j] == 1 && !v[i][j]) {
        a[c].x = i, a[c].y = j;
        dfs(i, j);
        c++;
      }
    }
  }
  sort(a, a + c, cmp);
  int p = c;
  for (int i = 0; i < c; i++) {
    if (p > k) {
      ans += a[i].area;
      p--;
      dfs1(a[i].x, a[i].y, 0);
    } else
      break;
  }
  cout << ans << endl;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m1; j++) {
      if (m[i][j])
        cout << ".";
      else
        cout << "*";
    }
    cout << endl;
  }
}
