L,K = map(int,input().split()) k = K * 2 l = L // k if L % k: eat = l * K else: eat = (l - 1) * K print(eat)