#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " : " << a << endl;
  err(++it, args...);
}
bool check(long long int val) {
  set<long long int> s;
  long long int cont = 0;
  while (val >= 1) {
    cont++;
    s.insert(val % 10);
    val /= 10;
  }
  if ((s).size() == cont)
    return true;
  else
    return false;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin.exceptions(cin.failbit);
  ;
  long long int l, r;
  cin >> l >> r;
  for (long long int i = l; i <= r; i++) {
    if (check(i)) {
      cout << i;
      return 0;
    }
  }
  cout << -1;
  return 0;
}
