chrysanthemum = int(input())
roses = int(input())
tulips = int(input())
season = input()
holiday = input()
total_flowers = chrysanthemum + roses + tulips
total_price = 0
if season == "Spring" or season == "Summer":
total_price += 2 * chrysanthemum
total_price += 4.1 * roses
total_price += 2.5 * tulips
if tulips > 7 and season == "Spring":
total_price *= 0.95
elif season == "Autumn" or season == "Winter":
total_price += 3.75 * chrysanthemum
total_price += 4.5 * roses
total_price += 4.15 * tulips
if roses >= 10 and season == "Winter":
total_price *= 0.9
if holiday == "Y":
total_price *= 1.15
if total_flowers > 20:
total_price *= 0.8
print(f"{2 + total_price:.2f}")