#include using namespace std; int main() { long long A, B; int it = 0; cin >> A >> B; long long sol = -1; while (A <= B && it <= 2) { if (__gcd(A, B) == 1) sol = max(sol, B - A + 1); A++; it++; } cout << sol << "\n"; return 0; }