import numpy n = int(input()) ts_lst = [ list(input().split(' ')) for i in range(n) ] correct_cnt = 0 wrong_cnt = 0 for ts in ts_lst: t = int(ts[0]) s = ts[1] s_len = len(s) leng = len(s) isCompleted = False while leng > 0: if numpy.floor(12*t/1000) >= leng: correct_cnt += leng wrong_cnt += s_len - leng isCompleted = True break else: leng -= 1 if not isCompleted: wrong_cnt += s_len print(correct_cnt) print(wrong_cnt)