#include <bits/stdc++.h>
const long long INF = 1000000007;
using namespace std;
int main() {
  long long A, B;
  cin >> A >> B;
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      if (i * j == A * B) {
        cout << i * j << endl;
        exit(0);
      }
    }
  }
  cout << -1 << endl;
  return 0;
}
