plen, spd = map(int, raw_input().split()) if plen % (spd * 2) == 0: print 0 else: print (plen / (spd * 2)) * spd