package com.company;

import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in, StandardCharsets.US_ASCII);
        int billTotal = 0;
        String input = scanner.nextLine();

        while (!input.isEmpty()){
            if(input.startsWith("|"))
                billTotal += 42 * input.length();
            else{
                String[] ordrinaryBill = input.split(",-");
                int price = Integer.parseInt(ordrinaryBill[0]);
                billTotal += price * ordrinaryBill[1].length();
            }
            input = scanner.nextLine();
        }
        int difference = billTotal % 10;
        if(difference < 5)
            billTotal -= difference;
        else
            billTotal += 10 - difference;

        String output = String.format("%d,-",billTotal);
        System.out.println(output);
        }
}

