L, K = map(int, input().split()) c = int(L/(K*2)) if((c == 1) and ((L % (K*2)) == 0)): print(0) else: print(c*K)