n=list(map(float,input().split())) if n[1]==11 and n[3]==1 and n[0]*0.7>50: print(f"{(n[0]*0.7-50):.2f}") elif n[1]==11 and n[3]==1 and n[0]*0.7<=50: print("0.00") elif n[1]==11 and n[3]==0: print(f"{(n[0]*0.7):.2f}") elif n[1]==12 and n[3]==1 and n[0]*0.8>50: print(f"{(n[0]*0.8-50):.2f}") elif n[1]==12 and n[3]==1 and n[0]*0.8<=50: print("0.00") else: print(f"{(n[0]*0.8):.2f}")