//na :cuixiaofei;
//da :08_11_11;
program crane;
var
n,m :longint;
a :array[1..100,1..100] of longint;
f1,f2 :text;
procedure init;
var
i,j :longint;
begin
assign(f1,'arcane.in');
reset(f1);
assign(f2,'arcane.out');
rewrite(f2);
readln(f1,n,m);
for i:=1 to n do
for j:=1 to m do
read(f1,a[i,j]);
end;
procedure diao;
begin
close(f1);
close(f2);
end;
procedure print;
var
i,j,ge :longint;
begin
ge:=0;
for i:=1 to n do
for j:=1 to m do
if a[i,j]=0 then
inc(ge);
if ge>=n*m div 2 then
begin
writeln(f2,0);
diao;
halt;
end;
ge:=0;
for i:=1 to n do
for j:=1 to m do
if a[i,j]=15 then
inc(ge);
if ge>=(n*m) div 2 then
begin
writeln(f2,1);
diao;
halt;
end;
if (n<5) and (m<5) then
writeln(f2,2)
else if (n<25) and (m<25) then
writeln(f2,10)
else
writeln(f2,1);
diao;
end;
begin
init;
print;
end.