#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
const long long mod = 1e9 + 7;
template <typename T>
T gcd(T a, T b) {
  return (b ? __gcd(a, b) : a);
}
template <typename T>
T lcm(T a, T b) {
  return (a * (b / gcd(a, b)));
}
void go() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
bool check(long long n) {
  long long a = n;
  long long c = 0;
  while (n) {
    c++;
    n /= 10;
  }
  set<long long> x;
  while (a) {
    x.insert(a % 10);
    a = a / 10;
  }
  return x.size() == c;
}
void solution() {
  long long l, r;
  cin >> l >> r;
  bool c;
  long long ans = 0;
  for (long long i = l; i <= r; ++i) {
    c = check(i);
    if (c) {
      ans = i;
      break;
    }
  }
  if (c)
    cout << ans << "\n";
  else
    cout << -1;
}
signed main() {
  go();
  solution();
  return 0;
}
