#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define int long #define ll long long #define rng(i,a,b) for(int i=int(a);i=int(a);i--) #define per(i,b) gnr(i,0,b) #define eb emplace_back #define all(x) x.begin(),x.end() #define SZ(x) x.size() #define fi first #define se second const int INF = 1e9; using namespace std; template using vc=vector; template using vvc=vc>; using pi=pair; using vi=vc; template inline bool chmax(T &a,T b){if(a inline bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;} int gcd(int a,int b){return b ? gcd(b,a%b) : a;} int lcm(int a,int b){return a/gcd(a,b)*b;} signed main() { cin.tie(0); ios::sync_with_stdio(0); cout<> A >> B; if(gcd(A,B)>=2) cout << -1 << endl; else { int cnt=0; map m; rng(i,1,lcm(A,B)+1){ rep(j,lcm(A,B)/A+1){ rep(k,lcm(A,B)/B+1){ if(i==j*A+k*B) m[i]++; } } } rng(i,1,lcm(A,B)+1){ if(m[i]==0) cnt++; } cout << cnt << endl; } }