buy = input().split(" ")
if buy[1]=='11':
    if buy[3]=='0':
        use_money = float(buy[0])*0.7
        print("%.2f" %use_money)
    elif buy[3]=='1':
        use_money = float(buy[0])*0.7 -50.0
        if use_money>=0.00:
            print("%.2f" %use_money)
        else:
            print("0.00")        
elif buy[1]=='12':
    if buy[3]=='0':
        use_money = float(buy[0])*0.8
        print("%.2f" %use_money)
    elif buy[3]=='1':
        use_money = float(buy[0])*0.8 - 50.0
        if use_money>=0.00:
            print("%.2f" %use_money)
        else:
            print("0.00")