Minimal d-exponent#2018

Minimal d-exponent

2 seconds
256 megabytes
Medium

Let be a prime number. Take an integer i \ge 0 and raise all integers from to p-1 to the power 2^i modulo . Denote the resulting set as S_i, and let d_i be the number of elements in this set. The -exponent of is defined as the minimum of all d_i over all possible i \ge 0.

You are given two positive integers and . Among all primes in the interval , find the minimum possible -exponent. It is guaranteed that there is at least one prime number in .

Input

The input consists of two positive integers and (2 \le A \le B \le 10^6).

Output

Output the single integer: the minimum -exponent among all prime numbers in the interval .

Examples

Example 1

Loading
Loading