function bomb(x,y,c,k){
   if(obj.hasOwnProperty(x+" "+y+" "+c))return;
   else obj[x+" "+y+" "+c]=true;
   max=Math.max(max,c);
   for(var i=0;i<4;i++){
      if(k<=0 && i<2)continue;
      var xx=x+dx[i];
      var yy=y+dy[i];
      if(xx<0 || yy<0 || xx>=w || yy>=h)continue;
      if(yx[yy][xx]=="#")continue;
      var kk=k;
      if(i<2)kk=kk-1;
      var plus=yx[yy][xx]-0;
      yx[yy][xx]=0;
      bomb(xx,yy,c+plus,kk);
      yx[yy][xx]=plus;
   }
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
input=input.replace(/\./g,"0");
var Arr=(input.trim()).split("\n");
var hwk=Arr.shift().split(" ").map(Number);
var h=hwk[0];
var w=hwk[1];
var K=hwk[2];
var yx=[];
for(var i=0;i<h;i++){
   var v=Arr.shift().split("");
   yx.push(v);
}
var max=0;
var obj={};
var dx=[0,-1,1,0];
var dy=[-1,0,0,1];
bomb(0,0,0,K);
console.log(max);