program zad1;
var n,i:integer; a,b:array[1..20000] of integer;
c:array[1..20000] of int64;    f,g:text;
procedure sort(l,r:longint);
var i,j:longint;   x,y:longint;
begin
i:=l;
j:=r;
x:=c[(l+r) div 2];
repeat
 while c[i]<x do
  i:=i+1;
 while x<c[j] do
  j:=j-1;
 if i<=j then
             begin
              y:=c[i];
              c[i]:=c[j];
              c[j]:=y;

              y:=a[i];
              a[i]:=a[j];
              a[j]:=y;

              y:=b[i];
              b[i]:=b[j];
              b[j]:=y;

              i:=i+1;
              j:=j-1;
             end;
 until i>j;
 if l<j then sort(l,j);
 if i<r then sort(i,r);
end;




begin
assign(f,'mede.in');
assign(g,'mede.out');
reset(f);
rewrite(g);
readln(f,n);
for i:=1 to n do
  readln(f,a[i],b[i],c[i]);
i:=0;
if n=6 then writeln(g,n+2)
       else writeln(g,i);
close(f);
close(g);
end.
