#P9390. 金盏花

金盏花

Problem Description

There is a 12-digit decimal number XX. You only know that the number formed by its last 6 digits is YY.

You are also given an integer ZZ. Among all possible XX, you need to find the minimum value of XZ\lvert X - Z \rvert.

Note that XX, YY, and ZZ have no leading zeros (that is, the most significant digit is not 00). Also, XX must have exactly 12 digits and YY must have exactly 6 digits.

Input Format

The first line contains two integers Y,ZY, Z.

Output Format

The first line contains one integer, the minimum value of XZ\lvert X - Z \rvert.

987654 123456123456

135802

428571 714285

99999714286

Hint

Sample #1 Explanation

Let X=123455987654X = 123455987654. The minimum value of XZ\lvert X - Z \rvert can be 135802135802.


Sample #2 Explanation

Let X=100000428571X = 100000428571. The minimum value of XZ\lvert X - Z \rvert can be 9999971428699999714286.


Constraints

For all testdata: 100000Y999999100000 \leq Y \leq 999999, 0Z10120 \leq Z \leq 10^{12}.

Subtask ID ZZ \leq Special Constraint Score
Subtask 1\text{Subtask 1} 00 Y=142857Y = 142857 2525
Subtask 2\text{Subtask 2} None
Subtask 3\text{Subtask 3} 999999999999
Subtask 4\text{Subtask 4} 101210^{12}

Translated by ChatGPT 5