#include <bits/stdc++.h>
using namespace std;
int main() {
  int l, r;
  cin >> l >> r;
  auto check = [](int i) {
    set<int> done;
    while (i) {
      if (done.count(i % 10) != 0) return false;
      done.insert(i % 10);
      i /= 10;
    }
    return true;
  };
  for (int i = l; i <= r; ++i) {
    if (check(i)) {
      cout << i;
      return 0;
    }
  }
  cout << -1;
}
