시간 제한메모리 제한제출정답맞힌 사람정답 비율
0.5 초 1024 MB168403523.026%

문제

\textit{In this problem, you have to find the next integer in a particular ordering with has the same set of prime divisors.}

Archaeologist Kris studies the ancient platform Flex which was recently found near Adobe creek. On this platform, the numbers of different versions of teleporters which have been created by The Elders were once inscribed. Each version number is an integer between $1$ and $N$. On the platform, there are several columns of numbers, one for each teleporter. Each column once listed all created versions of a teleporter in the order they were built. Unfortunately, some of the numbers were erased.

Kris just finished studying version $a$ of teleporter $b$, and he is now ready to examine the next version of this teleporter. But he does not even know its number! On the other hand, any program which is a correct solution of this problem must know it. Below is what Kris already knows about the version numbers of the teleporters:

  1. Each number from $1$ to $N$ is the number of some version of some teleporter.
  2. Different versions of one teleporter have different numbers.
  3. Each teleporter has its own set of prime numbers. Later, we consider one fixed teleporter. Let its prime number set be $X = \{p_1, p_2, \dots, p_m\}$ (we list them so that $p_1 < p_2 < \dots < p_m$).
  4. It is known that any version number of this teleporter is divisible by each prime from $X$ and not divisible by primes not in X. It means that such number can be written as $p_1^{k_1} p_2^{k_2} \dots p_m^{k_m}$ where $k_i \ge 1$. So, each version of this teleporter can be mapped to a tuple of $m$ positive integers $(k_1, k_2, \dots, k_m)$.
  5. Version $\alpha = (k_1, k_2, \dots, k_m)$ was built before version $\beta = (l_1, l_2, \dots, l_m)$ if and only if there is such $i$ ($0 \le i < m$) that $k_1 = l_1$, $k_2 = l_2$, $\dots$, $k_i = l_i$, but $k_{i+1} < l_{i+1}$. It can be said that the versions are ordered lexicographically by their tuples.

입력

The only line of input contains two integers --- the version number $a$ of a teleporter and the number $N$ ($1 \le a \le N \le 10^{18}$).

출력

If there exists a version of the same teleporter which was built just after version $a$, print its number. Otherwise, print "-1".

예제 입력 1

6 13

예제 출력 1

12

예제 입력 2

12 13

예제 출력 2

-1