v,m,d,t = map(float, input().split())
if m == 11 and d == 11:
    v *= 0.7
    if t == 1:
        v -= 50
elif m == 12 and d == 12:
    v *= 0.8
    if t == 1:
        v -= 50
if v < 0:
    print("0.00")
else:
    print("%.2f" % v)