/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.*;

public class Help {

	public static void main(String[] args) throws IOException{
    
    	
        int comandos=-1, val=0;
        short direcao=0;
		double posicao = 0;
		//crei a partir daqui
		 BufferedReader inputStream = null;
	     PrintWriter outputStream = null;

        try {
        	
        	inputStream = new BufferedReader(new FileReader("C:\\Users\\Notebook\\workspace\\ProblemaD\\src\\help.in"));
        	outputStream =  new PrintWriter(new FileWriter("C:\\Users\\Notebook\\workspace\\ProblemaD\\help.out"));

            String l;
            String n[] = new String[3];
            while ((l = inputStream.readLine()) != null) {
           	    
            	System.out.println(l);
            
            	val = Integer.parseInt(l);
     				
     				System.out.println(val);
					
                if (val==0){
                    break;
                }
                           
               	posicao = 0;
               	
           
               	System.out.println(l);
               	int corretas=0,somaTempo=0;	
               	String[] problemas=new String[300];
               	String[] pergunta=new String[val];
               	String[] perguntasCorretas=new String[val];
               	
               	for (int i=0;i<pergunta.length;i++)
               	{
               		pergunta[i]="";
               	}
               	for (int i=0;i<perguntasCorretas.length;i++)
               	{
               		perguntasCorretas[i]="";
               	}
               	String resposta="",respCorreta;
               	int tempo=0;
               	
               	 for (int x=0; x<val; x++){
               		l = inputStream.readLine(); 	
               		n=l.split(" ");
               		pergunta[x]=n[0];
               		tempo=Integer.parseInt(n[1]);
               		problemas[x]=n[2];
               		
               		if (problemas[x].equals("correct"))
               		{
               			somaTempo+=tempo;
               		    respCorreta=resposta;
               			corretas++;
               			perguntasCorretas[x]=n[0];
               		}	
               		
                 }
               	 System.out.println(perguntasCorretas.length);
               	for (int z=0;z<perguntasCorretas.length;z++)
               		System.out.println("PerguntasCorretas"+perguntasCorretas[z]);

               	for (int z=0;z<pergunta.length;z++)
               		System.out.println("Pergunta"+pergunta[z]);

               	
               	 int contaTentativas=0;
               	 
               	 
               	
                 for (int z=0;z<perguntasCorretas.length;z++)
                 {
                	 contaTentativas=0;
                	 for (String elementos:pergunta)
                 {
               		 
               		 if(elementos.equals(perguntasCorretas[z]))
               		 {
               		   System.out.println("corretas"+perguntasCorretas[z]);
               			 contaTentativas++;
               			 if(contaTentativas>=2)
               			 {
               			 somaTempo+=20;
               			 //contaTentativas=0;
               			 }
               			
               		 }
               	 }
                 }
               	 
               	 
               	System.out.println("Corretas..:"+corretas+" tempo..:"+somaTempo);
               	outputStream.println(corretas+" "+somaTempo);
 
            } // fecha o while

        } // fecha o try

        catch (Exception e) {
            System.out.println("Ocorreu um erro durante a leitura do arquivo!\n"+e);
            System.exit(0);
        } // fecha o catch
        finally{
                if (inputStream != null) {
                    inputStream.close();
                }
                if (outputStream != null) {
                    outputStream.close();
                }
            }

        }
        
 	}


	

