QOJ.ac

QOJ

حد الوقت: 2 s حد الذاكرة: 256 MB مجموع النقاط: 100

#22531. Cow Counting

الإحصائيات

Provenance: English mirror of the original statement: https://ac.nowcoder.com/acm/problem/25075

Archive cross-check: work/usaco_2007/open07/archive/analysis/analysis/OPEN07.count.htm and work/usaco_2007/open07/archive/testdata/count.1.in / .out.

Farmer John wants to label his $N$ cows, but cows do not like having the digit $L$ written on them, so he avoids that digit.

The cows receive the smallest set of $N$ positive integers whose decimal representations do not contain digit $L$. What is the largest label Farmer John must write?

Input

Line 1 contains two space-separated integers $N$ and $L$, where $1 \le N \le 1{,}000{,}000$ and $0 \le L \le 9$.

Output

Print one integer: the largest number Farmer John has to write on any cow.

Examples

Input 1

10 1

Output 1

22

The first ten positive integers without digit 1 are 2, 3, 4, 5, 6, 7, 8, 9, 20, 22.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.