#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long a, b;
  cin >> a >> b;
  for (long long i = a; i <= b; ++i) {
    vector<long long> r;
    ostringstream s;
    s << i;
    long long n = s.str().size();
    long long ic = i;
    while (ic) {
      r.push_back(ic % 10);
      ic /= 10;
    }
    sort(r.begin(), r.end());
    r.erase(unique(r.begin(), r.end()), r.end());
    if (n == r.size()) {
      cout << i;
      exit(0);
    }
  }
  cout << -1;
}
