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