#include <bits/stdc++.h>
template <class C, class E>
inline bool contains(const C& container, const E& element) {
  return container.find(element) != container.end();
}
template <class T>
inline void checkmin(T& a, T b) {
  if (b < a) a = b;
}
template <class T>
inline void checkmax(T& a, T b) {
  if (b > a) a = b;
}
using namespace std;
int n;
string s;
bool Check(int i) {
  if (i == 0) return true;
  vector<bool> d(10, false);
  while (i != 0) {
    int dig = i % 10;
    if (d[dig]) return false;
    d[dig] = true;
    i = i / 10;
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout << std::setprecision(15);
  cout << std::fixed;
  int l, r;
  cin >> l >> r;
  for (int i = (l), _b = (r); i <= _b; i++) {
    if (Check(i)) {
      cout << i;
      return 0;
    }
  }
  cout << -1;
  return 0;
}
