pockey,bite = (map(int,input().split())) if pockey<=bite*2: print(0) elif(pockey % (2 * bite) == 0): print((pockey // (2 * bite) - 1)*bite) else: print(pockey // (2 * bite)*bite)