n = int(input()) ans = 0 for i in range(n): t, s = input().split() t = int(t) ans += min(12 * t // 1000, len(s)) print(ans)