package bill;

import java.io.*;
import java.util.Scanner;

public class Bill {


    public static final String FOOD_SEPARATOR = ",";
    public static final int BEER_PRICE = 42;

    private static int getPrice(String line)   {
        int price = 0;
        if(line.contains(FOOD_SEPARATOR))
        {
            String[] split = line.split(FOOD_SEPARATOR);
            price += Integer.parseInt(split[0]) * split[1].substring(1).length();
        } else {
            int beerNum = line.length();
            price += beerNum * BEER_PRICE;
        }

        return price;
    }

    public static void main(String[] args) {
        // write your code here
        BufferedReader bufferedReader = null;
//        try {
//            bufferedReader = new BufferedReader(new FileReader("input.txt"));
            bufferedReader = new BufferedReader(new InputStreamReader(System.in));
//        } catch (FileNotFoundException e) {
//            e.printStackTrace();
//        }

        int beerNum;
        int beerPrice = 0;
        int foodPrice = 0;
        String inputLine;
        int total = 0;
        try {
            while (( inputLine = bufferedReader.readLine()) != null)    {
                total += getPrice(inputLine);
            }

        } catch (IOException e) {
            e.printStackTrace();
        }
        int increment = ((total) % 10);
        if (increment == 0)
        {
            System.out.println(total);
        } else {
            System.out.println(total + 10-increment);
        }

//        int num1 = scanner.nextInt();
//        int num2 = scanner.nextInt();
//        int length = scanner.nextInt();
//        int interested = scanner.nextInt();
//        if(interested != num1 && interested != num2)
//        {
//            System.out.println(0);
//            return;
//        }
//        long res = length;
//        for (int i = 0; i < length-1; i++) {
//            res = (res * 2) % 1000000007 ;
//        }
//        //res = (res * length ) % 1000000007;
//        //res = (res * length ) / 2;
//        if (num1 == num2) System.out.println(length);
//            //else System.out.println(res % 1000000007);
//        else System.out.println(res);
    }
}

