price,month,day,discount = input().split()

price = float(price)

if (month == '11') and (day == '11'):
    price *= 0.7
else:
    price *= 0.8

if discount == '1':
    price -= 50

if price < 0:
    price = 0

print(f'{price:.2f}')