

Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 150 点
問題文
あなたはコワスギ銀行の通帳を持っています。コワスギ銀行の預金通帳には、引き出し額に応じて手数料が変わるという怖すぎる性質があります。
コワスギ銀行の通帳からお金を引き出すには、1\,000 円単位で引き出し額を指定したうえで、引き出し額 1\,000 円あたり C 円の手数料を残高から別途支払う必要があります。銀行の残高が 0 円未満になる引き出しを行うことはできません。
あなたが持っているコワスギ銀行の通帳の残高が X 円のとき、そこから最大で何円を引き出せますか?
制約
- 1 \leq X \leq 10^7
- 1 \leq C \leq 999
- 入力される値はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
X C
出力
答えを出力せよ。
入力例 1
650000 8
出力例 1
644000
644\,000 円を引き出すために必要な手数料は 644\,000 \times \displaystyle\frac{8}{1000} = 5\,152 円になるので、644\,000 + 5\,152 \leq 650\,000 より、644\,000 円は引き出すことができます。
一方で、645\,000 円引き出すために必要な手数料は 645\,000 \times \displaystyle\frac{8}{1000} = 5\,160 円になるので、645\,000 + 5\,160 > 650\,000 より、645\,000 円は引き出すことができません。
入力例 2
1003 4
出力例 2
0
まったくお金が引き出せないこともありえます。
入力例 3
10000000 24
出力例 3
9765000
Score : 150 points
Problem Statement
You have a bankbook from The Terrifying Bank. The deposit passbook of the bank has a terrifyingly scary property that the commission fee changes according to the withdrawal amount.
To withdraw money from the passbook, you need to specify the withdrawal amount in units of 1\,000 yen, and pay a commission fee of C yen per 1\,000 yen of withdrawal amount separately from the balance. Withdrawals are not allowed if they would leave the balance below 0 yen.
When the balance of your passbook from the bank is X yen, what is the maximum amount of money you can withdraw from it?
Constraints
- 1 \leq X \leq 10^7
- 1 \leq C \leq 999
- All input values are integers.
Input
The input is given from Standard Input in the following format:
X C
Output
Output the answer.
Sample Input 1
650000 8
Sample Output 1
644000
The commission fee required to withdraw 644\,000 yen is 644\,000 \times \displaystyle\frac{8}{1000} = 5\,152 yen, so since 644\,000 + 5\,152 \leq 650\,000, you can withdraw 644\,000 yen.
On the other hand, the commission fee required to withdraw 645\,000 yen is 645\,000 \times \displaystyle\frac{8}{1000} = 5\,160 yen, so since 645\,000 + 5\,160 > 650\,000, you cannot withdraw 645\,000 yen.
Sample Input 2
1003 4
Sample Output 2
0
It is possible that no money can be withdrawn at all.
Sample Input 3
10000000 24
Sample Output 3
9765000