#include <bits/stdc++.h>
long long zero = 0;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return (a / gcd(a, b) * b); }
long long expo(long long x, long long y) {
  long long res = 1;
  x = x % 1000000007;
  while (y > 0) {
    if (y & 1) res = (1ll * res * x) % 1000000007;
    y = y >> 1;
    x = (1ll * x * x) % 1000000007;
  }
  return res;
}
long long ncr(long long n, long long r) {
  long long res = 1;
  if (r > n - r) r = n - r;
  for (long long i = 0; i < r; i++) {
    res *= n - i;
    res /= i + 1;
  }
  return res;
}
bool prime(long long n) {
  long long i;
  if (n == 1) return false;
  for (i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) return false;
  }
  return true;
}
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long l, r;
  cin >> l >> r;
  long long flg = 0;
  for (long long i = l; i <= r; i++) {
    long long num = i;
    bool visited[10] = {false};
    while (num) {
      if (visited[num % 10]) break;
      visited[num % 10] = true;
      num = num / 10;
    }
    if (num == 0) {
      cout << i;
      flg = 1;
      break;
    }
  }
  if (!flg) cout << "-1";
  return 0;
}
