/*机智sort二维转一维*/ #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #define maxn 50010 using namespace std; int n,s,num,c[maxn*6]; struct node { int l,r; }a[maxn*6]; int cmp(const node &x,const node &y) { if(x.l==y.l)return x.r>y.r; return x.l<y.l; } int init() { int x=0;char s=getchar(); while(s<'0'||s>'9')s=getchar(); while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();} return x; } void LIS() { for(int i=1;i<=num;i++) { int x=a[i].r; if(x>c[s]) { c[++s]=x;continue; } int p=lower_bound(c+1,c+1+s,x)-c; c[p]=x; } } int main() { n=init(); int x,y,z; for(int i=1;i<=n;i++) { x=init();y=init();z=init(); a[++num].l=x;a[num].r=y; a[++num].l=y;a[num].r=x; a[++num].l=x;a[num].r=z; a[++num].l=z;a[num].r=x; a[++num].l=y;a[num].r=z; a[++num].l=z;a[num].r=y; } sort(a+1,a+1+num,cmp); LIS(); printf("%d ",s); return 0; }