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