import java.util.*; public class TyperTakahashi { public static void main(String[] args){ Scanner scanner = new Scanner(System.in); try{ int Section = scanner.nextInt(); int Success = 0; int Failure = 0; if(Section<1 || Section>1000){ System.out.println("指定の範囲で入力してください"); System.exit(0); } for(int i = 0 ; i < Section ; i++){ int Time = scanner.nextInt(); String Text = scanner.next(); if(Time<1 || Time>30000){ System.out.println("指定の範囲で入力してください"); System.exit(0); } if(Text.length() > 12*Time/1000){ Failure += Text.length() - 12*Time/1000; Success += 12*Time/1000; }else{ Success += Text.length(); } } System.out.println(Success); System.out.println(Failure); }catch(InputMismatchException e){ System.out.println("数字を入力してください"); }catch(Exception E){ System.out.println("予期せぬエラー"); } } }