N = int(input()) s = 0 #成功 f = 0 #失敗 for i in range(N): l = input().split() t = int(l[0])*12//1000 #打てる文字数 w = len(l[1]) #課題の文字数 s += min(t,w) if t