L,K = map(int, input().split()) pocky = L//(K*2) if L%(K*2)==0: pocky-=1 ans = pocky*K print(ans)