#P3478. 「ROIR 2021 Day 2」好数

「ROIR 2021 Day 2」好数

Description

Translated from Chinese version of ROIR 2021 Day2 T2 Числа on this website.

We call those numbers satisfying that numbers on all digits are the same as Beautiful Numbers of type 11.

Additionally, we define Beautiful Numbers of type 22 as those satisfying any of the following conditions:

  • Is a beautiful number of type I.
  • Assume this is a number with tt digits and no prefix zeros, then the numbers on t1t-1 digits are the same.

Now you are given a value xx and your task is to find the first Beautiful Number of type k+1k+1 which satisfies x\geq x.

Input Format

The first line consists of a single integer xx.

The next line consists of a single integer kk.

Output Format

Output a single integer representing your answer.

700
0
777
700
1
700

Constraints

For all test data, it is guaranteed that 1x10171\le x\le 10^{17}k{0,1}k\in\{0,1\}

Subtask # Additional Constraints Score
11 1x1051\le x\le 10^5k=0k=0 1515
22 k=0k=0 2020
33 1x1051\le x\le 10^5 2121
44 No Additional Constraints 4444