L, K = map(int, input().split()) rest = L % (2 * K) if (rest == 0): print(int(L / 2) - K) else: print(int((L - rest) / 2))