#include #include #include using namespace std; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } int main(){ long long a,b; long long k,n; long long maxx = 0; cin >> a >> b; k = a; while(k < b && (b - k) > maxx){ n = b; while((n - k) > maxx){ if(gcd(k,n) == 1) maxx = n - k; --n; } ++k; } if(maxx > 0){ cout << maxx + 1; }else{ cout << -1; } return 0; }