m,n=map(int,input().split()) once=n*2 count=m//once if m%once==0: print((count-1)*n) else: print(count*n)