N, *TS = open(0).read().split() a, b = 0, 0 for t, s in zip(*[iter(TS)] * 2): x = 12 * int(t) // 1000 y = len(s) a += min(y, x) b += max(0, y - x) print(a, b)