n = int(input()) x, y = 0, 0 for _ in range(n): t, s = input().split() tn = (12 * int(t)) // 1000 d = len(s) - tn x += min(tn, len(s)) y += max(0, d) print(x, y)