#include <bits/stdc++.h>
using namespace std;
int main() {
  int l, r, flag = 0;
  cin >> l >> r;
  for (int i = l; i <= r; i++) {
    string s = to_string(i);
    set<int> u(s.begin(), s.end());
    if (u.size() == s.size()) {
      cout << s << "\n";
      flag = 1;
      i = r + 1;
    }
  }
  if (flag == 0) cout << -1 << "\n";
}
