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