Minimal d-rate
Medium
Execution time limit is 2 seconds
Runtime memory usage limit is 256 megabytes
Let p - a prime number. Take an integer i ≥ 0 and raise all the integers from 0 to p-1 degree 2^i modulo p. Denote the resulting set of numbers through S_i, and the number of elements in this set - via d_i. Called d-exponent of p smallest of the numbers d_i, for all possible i ≥ 0.
You are given two positive integers A and B. Among all the primes in the interval [A, B] is necessary to find such a figure whose d-minimal. It is guaranteed that in the interval [A, B] has at least one prime number.
Input
Two positive integers A and B (2 ≤ A ≤ B ≤ 10^6).
Output
The only integer - the minimum d-value for primes in the interval [A, B].
Examples
Input #1
Answer #1
Submissions 87
Acceptance rate 17%