balance=int(raw_input()) while True: withdraw=int(raw_input())
if withdraw <= 2000 and withdraw%5==0 and balance<=2000:
if withdraw<balance:
balance=(balance-(withdraw+0.50))
print "%.2f" % balance
else:
print "%.2f" % balance
else:
break