a,b=map(int,input().split()) c=2*b count=a//c if a==c: print(0) if a==count*c: print((count*b)-1) else: print(count*b)