#include<stdio.h>
#include<math.h>
int judge(int a,int b,int distance);
struct score
{
int numble;
int ChineseScore;
int MathScore;
int EnglishScore;
int sum
};
int main()
{
int N=0;
int count=0;
scanf("%d",&N);
struct score[1001];
for(int i=0;i<N;i++)
{
scanf("%d%d%d",&score.ChineseScore,
&score.MathScore,&EnglishScore);
sum=score.ChineseScore+score.MathScore+EnglishScore;
}
for(int i=0;i<N;i++)
{
for(int j=i;j<N;j++)
{
int flag=1;
flag=judge(score[i].ChineseScore,score[j].ChineseScore,5);
flag=judge(score[i].MathScore,score[j].MathScore,5);
flag=judge(score[i].EnglishScore,score[j].EnglishScore,5);
flag=judge(score[i].sum,score[j].sum,10);
if(flag)
count++;
}
}
}
int judge(int a,int b,int distance)
{
int flag=1;
if(abs(a-b)>distance)
flag=0;
return flag;
}
