﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _03.BikerRace_2_
{
    class Program
    {
        static void Main(string[] args)
        {
            double juniorsBikers = double.Parse(Console.ReadLine());
            double seniorsBikers = double.Parse(Console.ReadLine());
            string raceWay = (Console.ReadLine()).ToLower();

            double priceJuniors = 0;
            double priceSeniors = 0;


            switch (raceWay)
            {
                case "trail":
                    priceJuniors = 5.5;
                    priceSeniors = 7;
                    break;
                case "cross-country":
                    if (juniorsBikers + seniorsBikers > 50)
                    {
                        priceJuniors = 8 * 0.75;
                        priceSeniors = 9.5 * 0.75;
                    }
                    else
                    {
                        priceJuniors = 8;
                        priceSeniors = 9.5;
                    }
                    break;
                case "downhill":
                    priceJuniors = 12.25;
                    priceSeniors = 13.75;
                    break;
                case "road":
                    priceJuniors = 20;
                    priceSeniors = 21.50;
                    break;
            }

            var sum = juniorsBikers * priceJuniors + seniorsBikers * priceSeniors;
            var sumNetto = sum * 0.95;
            Console.WriteLine("{0:f2}", sumNetto);

            }
        }
    }
