#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long l, r;
  cin >> l >> r;
  for (long long i = l; i <= r; ++i) {
    string second = to_string(i);
    string t = second;
    sort(t.begin(), t.end());
    t.resize(unique(t.begin(), t.end()) - t.begin());
    if (second.size() == t.size()) {
      cout << i << '\n';
      exit(0);
    }
  }
  cout << "-1\n";
}
