L, K= map(int, input().split()) count= L // K*2 if count <= 1: U_length= 0 else: U_length= K * count print(U_length)