#include<stdio.h>
int main()
{
int i,n,temp=0;
scanf("%d",&n);
struct detail
{
int num;
char name[20];
int age;
union
{
int percent;
char letter;
} score;
} a[n];
for(i=0; i<n; i++)
{
scanf("%d",&a[i].num);
scanf("%s",&a[i].name);
scanf("%d",&a[i].age);
if(a[i].age<30)
{
scanf("%d",&a[i].score.percent);
}
else
{
scanf("%c",&a[i].score.letter);
}
}
for(i=0; i<n; i++)
{
if(a[i].age<30)
{
if(a[i].score.percent>=60)
{
temp++;
printf("%d\n",a[i].score.percent);
}
}
else
{
if(a[i].score.letter<'C')
{
temp++;
printf("%c\n",a[i].score.letter);
}
}
}
printf("%d",temp);
return 0;
}