#include <bits/stdc++.h>
using namespace std;
bool check(long long n) {
  vector<long long> freq(10, 0);
  bool ch = 1;
  while (n) {
    freq[n % 10]++;
    if (freq[n % 10] == 2) ch = 0;
    n /= 10;
  }
  return ch;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long l, r;
  cin >> l >> r;
  for (long long i = l; i <= r; i++) {
    if (check(i)) {
      cout << i;
      return 0;
    }
  }
  cout << -1;
  return 0;
}
