#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b % 2 != 0) res = (res * a) % 1000000007;
    a = (a * a) % 1000000007;
    b /= 2;
  }
  return res;
}
long long ncr(long long n, long long k) {
  if (k == 0 || k == n) return 1ll;
  if (k > n - k) k = n - k;
  long long pro = 1;
  for (long long i = 0; i < k; i++) {
    pro = (pro * (n - i)) % 1000000007;
    pro /= (i + 1);
  }
  return (pro % 1000000007);
}
vector<int> prime;
void seive() {
  vector<bool> isprime(1000001, true);
  for (int i = 2; i * i <= 1000000; i++) {
    if (isprime[i]) {
      for (int j = i * i; j <= 1000000; j += i) {
        isprime[j] = false;
      }
    }
  }
  for (int i = 2; i <= 1000000; i++) {
    if (isprime[i]) prime.push_back(i);
  }
}
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int l, r;
  cin >> l >> r;
  int flag = 0;
  vector<int> freq(10, 0);
  for (int i = l; i <= r; i++) {
    freq.clear();
    flag = 0;
    freq.resize(10, 0);
    int num = i;
    while (num > 0) {
      int rem = num % 10;
      num /= 10;
      freq[rem]++;
    }
    for (int j = 0; j < 10; j++) {
      if (freq[j] > 1) {
        flag = 1;
        break;
      }
    }
    if (flag == 0) {
      cout << i;
      return 0;
    }
  }
  cout << "-1";
  return 0;
}
