import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) { BufferedReader buff = new BufferedReader(new InputStreamReader(System.in)); try { final double tp = 1000d / 12d; int count = Integer.parseInt(buff.readLine()); int acc = 0, miss = 0; while (count-- > 0) { String[] str = buff.readLine().split(" "); int limitTime = Integer.parseInt(str[0]); int limitChar = (int)(limitTime / tp); if (limitChar < str[1].length()) { acc += limitChar; miss += str[1].length() - limitChar; } else { acc += str[1].length(); } } System.out.println(acc + " " + miss); } catch (NumberFormatException e) { } catch (IOException e) { } } }