const n=8; m=12;
var c: array [1..n,1..m] of integer;
    i, j, k, l:integer; tl, tp:boolean;
begin
for i:=1 to n do
 begin
 for j:=1 to m do read(c[i,j]);
 readln;
 end;
k:=0;
for i:=1 to n do
 begin
 for j:=1 to m do
  begin
  tl:=true; tp:=true;
  for l:=1 to j-1 do if c[i,l]>=c[i,j] then tl:=false;
  for l:=j+1 to m do if c[i,l]<=c[i,j] then tp:=false;
  if tl and tp then k:=k+1;
  end;
 end;
writeln(k); readln;
end.