import java.util.*; public class Exercise113{ public static void main (String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int r = 0; int w = 0; for(int i = 0; i < n; i++){ int t = sc.nextInt(); String s = sc.next(); r += Math.min(t * 12 / 1000, s.length()); w += s.length() - Math.min(t * 12 / 1000, s.length()); } System.out.println(r + " " + w); } }