Codeforces Round 135 (Div. 2)
B
Special Offer! Super Price 999 Bourles!
Codeforces
1400
原题
← AC →
翻译中…

Polycarpus is an amateur businessman. Recently he was surprised to find out that the market for paper scissors is completely free! Without further ado, Polycarpus decided to start producing and selling such scissors.

翻译中…

Polycaprus calculated that the optimal celling price for such scissors would be $*p*$ bourles. However, he read somewhere that customers are attracted by prices that say something like "Special Offer! Super price 999 bourles!". So Polycarpus decided to lower the price a little if it leads to the desired effect.

翻译中…

Polycarpus agrees to lower the price by no more than $*d*$ bourles so that the number of nines at the end of the resulting price is maximum. If there are several ways to do it, he chooses the maximum possible price.

翻译中…

Note, Polycarpus counts only the trailing nines in a price.

翻译中…

Input

翻译中…

The first line contains two integers $*p*$ and $*d*$ ($1 ≤ *p* ≤ 10^{18}$; $0 ≤ *d* < *p*$) — the initial price of scissors and the maximum possible price reduction.

翻译中…

Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specifier.

翻译中…

Output

翻译中…

Print the required price — the maximum price that ends with the largest number of nines and that is less than $*p*$ by no more than $*d*$.

翻译中…

The required number shouldn't have leading zeroes.

翻译中…

样例

Input #1
1029 102
Output #1
999
InputCopy OutputCopy
Input #2
27191 17
Output #2
27189
InputCopy OutputCopy
题目信息
题号
219B
时间限制
1 s
内存限制
256 MB
标签
模拟

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。