#include <bits/stdc++.h>
using namespace std;
bool check(int n) {
  int cnt = 0;
  map<int, int> freq;
  while (n) {
    freq[n % 10]++;
    n /= 10;
    cnt++;
  }
  return cnt == freq.size();
}
void solve() {
  int l, r;
  cin >> l >> r;
  for (int i = l; i < r + 1; i++) {
    if (check(i)) {
      cout << i;
      return;
    }
  }
  cout << -1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t = 1;
  while (t--) {
    solve();
    cout << '\n';
  }
  return 0;
}
