Transactions#2515

Transactions

2 segundos
256 megabytes
Difícil (≈1650)

Any large organization often uses banks to transfer money to its partners, or to receive amounts owed to it. At the same time, banks earn income by charging fees for these operations.

A developing bank that handles money transfers only performs a transaction if the transferred amount can be written in the decimal system using only ones. Due to this rule, the bank does not have many clients, so its management decided to conduct a promotional campaign: if a client makes several transfers at once, and the total number of ones in all transfers equals , all transfers will be free. Each client can use this promotion only once.

One client wants to transfer the amount to a partner. The client decided to take advantage of this offer and make the transfer for free. To do this, must be split into terms, each written in decimal using only ones, and the total number of ones in all terms must equal .

To reduce reporting paperwork, the client wants to split into the minimum number of terms.

For example, if x = 134 and k = 26, the optimal split is transfers of and transfers of .

Entrada

The single line of the input contains two integers: (1 \le x \le 10^{18}) — the amount to be transferred, and (1 \le k \le 500) — the required total number of ones in the transfers.

Salida

Print a single number — the minimum number of terms into which can be split according to the requirements, or the word Impossible if it is not possible.

Ejemplos

Ejemplo 1

Loading
Loading