Alexandra and A*B Problem

Accepts: 17
Submissions: 351
Time Limit: 2000/1000 MS (Java/Others)
Memory Limit: 32768/32768 K (Java/Others)
Problem Description
Alexandra has a little brother. He is new to programming. One day he is solving the following problem: Given two positive integers A and B, output A*B. This problem is even easier than the last one. Alexandra can't wait to give him another task: Given a positive integer A and a string S(S only contains numbers.), find the minimum positive integer B, such that S is a substring of T, where T is the decimal notation of A*B. See the sample for better understanding. Note: S can contain leading zeros, but T can't.
Input
There are multiple test cases (no more than 500). Each case contains a positive integer A and a string S. $A \leq 10,000, 1 \leq |S| \leq 8$.
Output
For each case, output the required B. It is guaranteed that such B always exists. To C++ programmers: if you want to output 64-bit integers, please use "%I64d" specifier or cout.
Sample Input
6 8
96 19
2 0086
1 1
Sample Output
3
2
5043
1