e-olymp
favorite We need a little bit of your help to keep things running, click on this banner to learn more
Problems

Digits

Digits

A positive integer which is equal to Cn, where С = 1..9 contains at least K numbers C. For given numbers C and K find the smallest value of N.

Input

In the input file contains two numbers С and K, K500.

Output

One number N.

Time limit 1 second
Memory limit 64 MiB
Input example #1
9 2
Output example #1
5

Example description: 9^5=59049 – set of 2 digit 9.

Author Zhukovsky S.S.
Source Stage III All-Ukrainian School Olympiad 2010-2011, Round 2, Zhytomyr