n = int(input()) ts_list = [] for i in range(n): t, s = input().split() t = int(t) ts_list.append([t, s]) rate = 1000 / 12 ok_count = 0 ng_count = 0 for t, s in ts_list: tmp_ok = int(t // rate) ok_count += min(tmp_ok, len(s)) ng_count += len(s) - min(tmp_ok, len(s)) print(ok_count, ng_count)