import math def main(): l, k = map(int, input().split()) if l/2 > k and l/2 % k == 0: print(round(((l/2)//k)*k)-k) else: if l/2 > k: print(round(((l/2)//k)*k)) else: print(0) if __name__ == '__main__': main()