price,month,day,ticket = map(float, input().split(' '))
if int(month)==11:
    cost = price*0.7 - ticket*50
    if cost<0:
        cost = 0
    print(f'{cost:.2f}')
else:          #注:输入日期保证只有“双11”和“双12”。
    cost = price*0.8 - ticket*50
    if cost<0:
        cost = 0
    print(f'{cost:.2f}')