#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, cnt = 0, k = 0, ar[100];
  bool f = false;
  cin >> a >> b;
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      {
        ar[k] = i * j;
        k++;
      }
    }
  }
  sort(ar, ar + k);
  for (int i = 1; i < k; i++) {
    if (ar[i] % (a * b) == 0) {
      f = true;
      break;
    }
  }
  if (f)
    cout << a * b << endl;
  else
    cout << "-1" << endl;
  return 0;
}
