#include using namespace std; int main() { long long a, b; cin >> a >> b; for(long long diff=b-a+1;diff>=0;diff--) { for(long long x=a, y=x+diff; y<=b; x++, y++) { if(__gcd(x, y) == 1) { cout << diff + 1; return 0; } } } cout << -1; return 0; }