import java.util.Scanner; public class Main { public static void main(String[] a) { Scanner s=new Scanner(System.in); s.nextInt(); int T=0,E=0,L; while(s.hasNext()){ int S=s.nextInt()*12/1000-(L=s.next().length()); T+=L;E-=S<0?S:0; } System.out.println((T-E)+" "+E); } }