#include <bits/stdc++.h>
using namespace std;
#define maxN 52
char a[maxN][maxN];
int visited[maxN][maxN];
int mark[maxN][maxN];
bool lake;
int numadj,n,m;
vector < pair <int, pair <int,int> > > v;
void checklake(int x,int y)
{
visited[x][y]=1;
numadj++;
if(x==0||x==n-1||y==m-1||y==0)
{
lake=false;
return ;
}
if(!visited[x][y+1]&&a[x][y+1]=='.')checklake(x,y+1);
if(!visited[x][y-1]&&a[x][y-1]=='.')checklake(x,y-1);
if(!visited[x+1][y]&&a[x+1][y]=='.')checklake(x+1,y);
if(!visited[x-1][y]&&a[x-1][y]=='.')checklake(x-1,y);
}
void ffill(int x,int y)
{
a[x][y]='*';
mark[x][y]=1;
if(a[x][y+1]=='.'&&!mark[x][y+1])ffill(x,y+1);
if(a[x][y-1]=='.'&&!mark[x][y-1])ffill(x,y-1);
if(a[x+1][y]=='.'&&!mark[x+1][y])ffill(x+1,y);
if(a[x-1][y]=='.'&&!mark[x-1][y])ffill(x-1,y);
}
int main() {
std::ios::sync_with_stdio(false);
int k,ans=0;
cin>>n>>m>>k;
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
cin>>a[i][j];
}
}
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
visited[i][j]=0;
mark[i][j]=0;
}
}
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{ numadj=0;
if(a[i][j]=='.'&&!visited[i][j])
{ lake=true;
checklake(i,j);
if(lake)
{
v.push_back({numadj,{i,j}});
}
}
}
}
sort(v.begin(),v.end());
for(int i=0;i<v.size()-k;i++)
{
ans+=v[i].first;
ffill(v[i].second.first,v[i].second.second);
}
cout<<ans<<endl;
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
cout<<a[i][j];
}
cout<<endl;
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgbWF4TiA1MgpjaGFyIGFbbWF4Tl1bbWF4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2luPj5uPj5tPj5rOwoJZm9yKGludCBpPTA7aTxuO2krKykKCXsKCSAgICBmb3IoaW50IGo9MDtqPG07aisrKQoJICAgIHsgCgkgICAgICAgIGNpbj4+YVtpXVtqXTsKCSAgICAgICAKCSAgICB9Cgl9CgkJZm9yKGludCBpPTA7aTxuO2krKykKCXsKCSAgICBmb3IoaW50IGo9MDtqPG07aisrKQoJICAgIHsgCgkgICAgICAgIAoJICAgICAgIHZpc2l0ZWRbaV1bal09MDsKCSAgICAgICAgbWFya1tpXVtqXT0wOwoJICAgIH0KCX0KCSAKCWZvcihpbnQgaT0wO2k8bjtpKyspCgl7CgkgICAgZm9yKGludCBqPTA7ajxtO2orKykKCSAgICB7ICAgbnVtYWRqPTA7CgkgICAgICAgIGlmKGFbaV1bal09PScuJyYmIXZpc2l0ZWRbaV1bal0pCgkgICAgICAgIHsgICBsYWtlPXRydWU7CgkgICAgICAgICAgICBjaGVja2xha2UoaSxqKTsKCSAgICAgICAgICAgIAoJICAgICAgICAgICAgaWYobGFrZSkKCSAgICAgICAgICAgIHsKCSAgICAgICAgICAgICAgICB2LnB1c2hfYmFjayh7bnVtYWRqLHtpLGp9fSk7CgkgICAgICAgICAgICB9CgkgICAgICAgIH0KCSAgICB9Cgl9Cglzb3J0KHYuYmVnaW4oKSx2LmVuZCgpKTsKCQoJZm9yKGludCBpPTA7aTx2LnNpemUoKS1rO2krKykKCXsKCSAgICBhbnMrPXZbaV0uZmlyc3Q7CgkgICAgZmZpbGwodltpXS5zZWNvbmQuZmlyc3QsdltpXS5zZWNvbmQuc2Vjb25kKTsKCX0KCWNvdXQ8PGFuczw8ZW5kbDsKCQlmb3IoaW50IGk9MDtpPG47aSsrKQoJewoJICAgIGZvcihpbnQgaj0wO2o8bTtqKyspCgkgICAgeyAKCSAgICAgICAgY291dDw8YVtpXVtqXTsKCSAgICB9CgkgICAgY291dDw8ZW5kbDsKCX0KCXJldHVybiAwOwp9Cg==