Nitoiu

Time limit: 0.25s
Memory limit: 256MB
Input:
Output:

Nitoiu found out that he sings really reaally bad so he wants a career change. While expanding his skillset, he discovered that he is very good at arithmetic operations.

His old producer Sake doesn't like the idea of losing a long time collaborator so he wants to discourage Nitoiu by proving that he is not as good at arithmetics as he thinks he is.

Sake gives Nitoiu two integers NN, KK and asks him the minimum number of concatenations of NN with itself such that the result is divisible by KK. If by concatenating NN with itself any number of times it is impossible to find a multiple of KK the answer is considered 1-1.

Nitoiu promises that he will cover your favorite song if you help him with this task.

Input data

The only line contains two integers NN and KK (1N1091 \leq N \leq 10^9, 1K1051 \leq K \leq 10^5).

Output data

Output a single integer - the minimum number of concatenations needed to obtain a multiple of KK or -1 if this is impossible.

Constraints and clarifications

  • For 2020 points it is guaranteed that N<10N < 10, K18K \leq 18 and the lowest multiple is less than 101810^{18}
  • For another 2020 points it is guaranteed that N<10N < 10, K1 000K \leq 1 \ 000 and the result is less than 10410^4.
  • For another 2020 points it is guaranteed that N<10N < 10, K105K \leq 10^5 and the result is less than 10710^7.
  • For another 2020 points it is guaranteed that N1 000N \leq 1 \ 000, K105K \leq 10^5 and the result is less than 10710^7.
  • The last 2020 points are given for tests where N109N \leq 10^9 and K105K \leq 10^5.

Example

stdin

2 6

stdout

2

Explanation

The minimum number of concatenations needed is 22 because 222222 is divisible by 66 and 2222 is not divisible by 66.

Log in or sign up to be able to send submissions!