/* */ //#pragma comment(linker, "/STACK:16777216") #define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define y0 sdkfaslhagaklsldk #define y1 aasdfasdfasdf #define yn askfhwqriuperikldjk #define j1 assdgsdgasghsf #define tm sdfjahlfasfh #define lr asgasgash #define eps 1e-9 #define M_PI 3.141592653589793 #define bs 1000000007 #define bsize 512 const int N = 1000; using namespace std; long long l, r, ans; long long gcd(long long a, long long b) { while (a&&b)a > b ? a %= b : b %= a; return a + b; } int main(){ //freopen("route.in","r",stdin); //freopen("route.out","w",stdout); //freopen("F:/in.txt", "r", stdin); //freopen("F:/output.txt", "w", stdout); ios_base::sync_with_stdio(0); //cin.tie(0); cin >> l >> r; ans = -1; for (long long i = l; i <= l + 1; i++) { for (long long j = r; j >= r - 1; j--) { if (i >= l&&i <= r&&j >= l&&j <= r&&gcd(i, j) == 1) ans = max(ans, j - i + 1); } } cout << ans << endl; // cin.get(); cin.get(); return 0; }