# coding:utf-8 L, K = map(int,input().split()) haruka_K = 0 yuu_K = 0 K_length = L // (2 * K) nokori_L = L % (2 * K) if L <= 2 * K: print(0) else: haruka_K = (L // 2) + nokori_L print(L - haruka_K)