program Teren;
label
001;
const
ii_0 : array[1..8] of integer = (1, 1, 1, 0, 0, -1, -1, -1);
jj_0 : array[1..8] of integer = (1, -1, 0, 1, -1, 0, -1, 1);
var
ind : boolean;
fl : text;
a : array[1..300,1..300] of byte;
b : array[1..300,1..300] of integer;
pi, pj : array[1..10000] of integer;
n, k, j, s, i, m, pas, cant, x, s_aux, p, n1, v_pas : integer;
procedure Init;
var
i, j :integer;
begin
for i := 1 to m do
for j := 1 to n do
b[i,j] := a[i,j];
end;
begin
assign(fl,'teren.in');
reset(fl);
readln(fl,m,n,x);
for i := 1 to m do
for j := 1 to n do
read(fl,a[i,j]);
close(fl);
n1 := 0;
for i := 1 to m do
for j := 1 to n do
if a[i,j] = 1 then
begin
n1 := n1 + 1;
pi[n1] := i;
pj[n1] := j;
end;
s := 0;
s_aux := 0;
for k := 1 to n1 do
begin
cant := 0;
b[pi[k],pj[k]] := 2;
pas := 2;
while cant < x do
begin
for i := 1 to m do
for j := 1 to n do
if b[i,j] = pas then
begin
for p := 1 to 8 do
if (b[i+ii_0[p],j+jj_0[p]] = 1) and (i+ii_0[p] <> pi[k]) and (j+jj_0[p]<> pj[k]) then
begin
cant := cant + 1;
if cant = x then
v_pas := pas;
end;
if cant > x then
goto 001;
for p := 1 to 8 do
if b[i+ii_0[p],j+jj_0[p]] = 0 then
b[i+ii_0[p],j+jj_0[p]] := pas +1;
end;
pas := pas + 1;
end;
001: ;
s_aux := 0;
for i := 1 to m do
for j := 1 to n do
if (b[i,j] <= v_pas) and (b[i,j] <> 0) and (b[i,j] <> 1) then
s_aux := s_aux + 1;
if s_aux > s then
s := s_aux;
Init;
end;
assign(fl,'teren.out');
rewrite(fl);
writeln(fl,s);
close(fl);
end.