n = int(input()) t_str = ["" for i in range(n)] s_str = ["" for i in range(n)] for i in range(n): t_str[i], s_str[i] = map(str, input().split()) t_set = set(t_str) t = [int(i) for i in t_set] s = [len(i) for i in s_str] p_cnt = 0 s_cnt = 0 for i in range(n): uteru = (t[i]*12)//1000 if uteru >= s[i]: p_cnt += s[i] else: p_cnt += uteru s_cnt += s[i]-uteru print(str(p_cnt)+" "+str(s_cnt))