#include using namespace std; #define int long long #define pb push_back #define mp make_pair #define fr first #define sc second #define Rep(i, n) for( int i = 0; i < (n); i++ ) #define Rrep(i, a, n) for( int i = (a); i < (n); i++ ) #define All(v) v.begin(), v.end() typedef pair Pii; typedef pair Pip; const int INF = 1107110711071107; signed main() { int n, m; cin >> n >> m; if ( n == 2 || (n == 3 && m == 3) || m == 1 ) cout << 1 << endl; else cout << -1 << endl; return 0; }