# Required Length solution codeforces

## Required Length solution codeforces

You are given two integer numbers, nn and xx. You may perform several operations with the integer xx.

Each operation you perform is the following one: choose any digit yy that occurs in the decimal representation of xx at least once, and replace xx by xyx⋅y.

You want to make the length of decimal representation of xx (without leading zeroes) equal to nn. What is the minimum number of operations required to do that?

Input

The only line of the input contains two integers nn and xx (2n192≤n≤191x<10n11≤x<10n−1).

Output

Print one integer — the minimum number of operations required to make the length of decimal representation of xx (without leading zeroes) equal to nn, or 1−1 if it is impossible.

Examples
input

Copy
2 1

output

Copy
-1

input

Copy
3 2

output

Copy
4

input

Copy
13 42

output

Copy
12

Note

In the second example, the following sequence of operations achieves the goal:

1. multiply xx by 22, so x=22=4x=2⋅2=4;
2. multiply xx by 44, so x=44=16x=4⋅4=16;
3. multiply xx by 66, so x=166=96x=16⋅6=96;
4. multiply xx by 99, so x=969=864x=96⋅9=864.