PL, K = map(int, input().split()) length = 0 while PL > 2 * K: PL -= 2 * K length += K print(length)