import fileinput


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