#coding:utf-8 L,K=map(int,raw_input().split()) if L <= K*2: print 0 else: if L % (K*2) == 0: print (L//(K*2)*K-K) else: print (L//(K*2))*K