import fileinput


totalPrice = 0
for str in fileinput.input():
    if str[0] == "|":
        totalPrice += len(str.split()) * 42
    else:
        price = int(str[0:str.find(",")])
        totalPrice += len(str.split("-")[1].split()) * price
print((totalPrice // 10) * 10 + 10)
