young_cyclist = int(input())
old_cyclist = int(input())
type_of_trace = input()
total = 0
if type_of_trace == "trail":
total = young_cyclist * 5.5 + old_cyclist * 7
elif type_of_trace == "cross-country":
total = young_cyclist * 8 + old_cyclist * 9.5
if young_cyclist + old_cyclist >= 50:
total *= 0.75
elif type_of_trace == "downhill":
total = young_cyclist * 12.25 + old_cyclist * 13.75
else:
total = young_cyclist * 20 + old_cyclist * 21.5
total *= 0.95
print(f"{total:.2f}")