#include <bits/stdc++.h>
using namespace std;
const long double EPS = 1e-5;
const long double PI = acos(-1);
int mod = (int)998244353;
const int MOD7 = 1000000007;
const int MOD9 = 1000000009;
const int a228 = 18;
const long long kekmod = 1791791791;
const long long bestmod = 1148822869;
vector<long long> mods = {kekmod, bestmod, mod, MOD9, 1000000007};
vector<long long> hashpows = {29, 31, 37, 43, 47, 53, 179, 229};
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count() +
            228 + 'i' + 'q' + 1337 + 1488);
long long MOD = mods[rnd() % mods.size()];
long long hashpow = hashpows[rand() % hashpows.size()];
bool check(int n) {
  for (int i = 2; i * i <= n; ++i) {
    if (n % i == 0) return 0;
  }
  return 1;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  srand(time(NULL));
  int a, b;
  cin >> a >> b;
  int n = a * b;
  for (int i = 1; i <= 9; ++i) {
    if (n % i == 0) {
      if (n / i <= 9) {
        cout << n;
        return 0;
      }
    }
  }
  cout << -1;
}
