/**
 * Created by xXxCKxXx on 10/28/2016.
 */

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class Main {
    public static void main(String [] args) throws FileNotFoundException, IOException{
        File f = new File(args[0]);
        BufferedReader read = new BufferedReader(new FileReader(f));

        String line;
        while ((line = read.readLine()) != null){
            //create a String array out of the elements of the String
            String [] array = line.split(",");
            //trim off any whitespace from the head or tail of the string
            array[0] = array[0].trim();
            array[1] = array[1].trim();
            array[2] = array[2].trim();
            array[3] = array[3].trim();
            //print the answer
            System.out.println((int)(Math.floor(((3*(Integer.parseInt(array[0].substring(array[0].indexOf(":") + 2)))+4*(Integer.parseInt(array[1].substring(array[1].indexOf(":") + 2)))+5*(Integer.parseInt(array[2].substring(array[2].indexOf(":") + 2))))*(Integer.parseInt(array[3].substring(array[3].indexOf(":") + 2)))) / ((Integer.parseInt(array[0].substring(array[0].indexOf(":") + 2))) + (Integer.parseInt(array[1].substring(array[1].indexOf(":") + 2))) + (Integer.parseInt(array[2].substring(array[2].indexOf(":") + 2)))))));
        }
    }
}