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

namespace Flowers
{
    class Program
    {
        static void Main(string[] args)
        {
            int chrysanthemums = Int32.Parse(Console.ReadLine());
            int roses = Int32.Parse(Console.ReadLine());
            int tulips = Int32.Parse(Console.ReadLine());
            string season = Console.ReadLine();
            char holiday = Char.Parse(Console.ReadLine());

            //first half of the year
            if (season == "Spring")
            {
                var price = chrysanthemums * 2 + roses * 4.10 + tulips * 2.5;
                //holiday check
                if (holiday == 'Y')
                {
                    price += price * 0.15;
                }
                if (tulips>7)
                {
                    price -= price * 0.05;
                }
                if (chrysanthemums+roses+tulips>20)
                {
                    price -= price * 0.20;
                }
                price += 2;
                Console.WriteLine("{0:f2}",price);
            }

            if (season == "Summer")
            {
                var price = chrysanthemums * 2 + roses * 4.10 + tulips * 2.5;
                if (holiday == 'Y')
                {
                    price += price * 0.15;
                }
                if (chrysanthemums + roses + tulips > 20)
                {
                    price -= price * 0.20;
                }
                price += 2;
                Console.WriteLine("{0:f2}", price);
            }

            //second half of the year
            if (season == "Autumn")
            {
                var price = chrysanthemums * 3.75 + roses * 4.50 + tulips * 4.15;
                if (holiday == 'Y')
                {
                    price += price * 0.15;
                }
                if (chrysanthemums + roses + tulips > 20)
                {
                    price -= price * 0.20;
                }
                price += 2;
                Console.WriteLine("{0:f2}", price);
            }

            if(season == "Winter")
            {
                var price = chrysanthemums * 3.75 + roses * 4.50 + tulips * 4.15;
                if (holiday == 'Y')
                {
                    price += price * 0.15;
                }
                if (roses >= 10)
                {
                    price -= price * 0.10;
                }
                if (chrysanthemums + roses + tulips > 20)
                {
                    price -= price * 0.20;
                }
                price += 2;
                Console.WriteLine("{0:f2}", price);
            }
        }
    }
}
