#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,b) for(int i=a;i<=b;i++)
inline ll r() {
	ll x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c))x=x*10+c-'0',c=getchar();
	return x*f;
}
#define d r()
ll n,m,k,ans,mod=1000000007;
ll qp(ll a,ll b,ll p){
	ll ans=1;
	while(b){
		if(b&1)ans=ans*a%p;
		a=a*a%p;
		b/=2;
	}
	return ans;
}
ll jc(ll x){
	ll ans=1;
	f(i,1,x)ans=ans*i%mod;
	return ans;
}
ll C(ll n,ll m,ll s){
	ll ans=1;
	f(i,m-s+1,m+n)ans=ans*i%mod;
	return ans*qp(jc(s+n),mod-2,mod)%mod;
}
int main(){
	n=d,m=d;
	f(i,1,n)k+=d;
	printf("%lld",C(n,m,k));
	return 0;
}
#include <iostream>
using namespace std;
int main(void) {
    int a, b;
    cin >> a >> b;
    int bp = b - a;
    int p = bp;
    int d = a % p ? p - a % p : 0;
    while (d + p > bp) {
        p--;
        d = a % p ? p - a % p : 0;
    }
    cout << p << endl;
}