#include <bits/stdc++.h>
using namespace std;
int n, m, k;
char graph[55][55];
vector<pair<int, int> > v[3000];
int ct;
int flag;
int dx[] = {0, 0, -1, 1};
int dy[] = {-1, 1, 0, 0};
bool visited[55][55];
vector<pair<int, int> > vt;
bool isOcean(int x, int y) {
  if (x == 0 || x == n - 1 || y == 0 || y == m - 1) {
    if (graph[x][y] == '.') {
      return true;
    }
  }
  return false;
}
void dfs(int x, int y) {
  if (x < 0 || x >= n || y < 0 || y >= m) {
    return;
  }
  if (graph[x][y] != '.' || visited[x][y]) {
    return;
  }
  if (isOcean(x, y)) {
    flag = 1;
    return;
  }
  visited[x][y] = true;
  vt.push_back(pair<int, int>(x, y));
  for (int i = 0; i < 4; i++) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    dfs(nx, ny);
  }
}
bool compare(vector<pair<int, int> > a, vector<pair<int, int> > b) {
  return a.size() < b.size();
}
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> graph[i][j];
    }
  }
  ct = 0;
  for (int i = 0; i < 55; i++) {
    for (int j = 0; j < 55; j++) {
      visited[i][j] = false;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (graph[i][j] == '.' && !visited[i][j]) {
        flag = 0;
        vt.clear();
        dfs(i, j);
        if (!flag) {
          v[ct] = vt;
        }
        ct++;
      }
    }
  }
  sort(v, v + ct, compare);
  int st = 0;
  int ans = 0;
  while (st < ct - k) {
    int len = v[st].size();
    ans += len;
    for (int i = 0; i < len; i++) {
      graph[v[st][i].first][v[st][i].second] = '*';
    }
    st++;
  }
  cout << ans << endl;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cout << graph[i][j];
    }
    if (i != n - 1) {
      cout << endl;
    }
  }
  return 0;
}
