#include <bits/stdc++.h>
using namespace std;
void FastInputOutput() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
inline int D() {
  int t;
  scanf("%d", &t);
  return t;
}
inline long long LLD() {
  long long t;
  scanf("%lld", &t);
  return t;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long power(long long x, long long p, long long m) {
  long long res = 1;
  while (p) {
    if (p & 1) res = (res * x) % m;
    x = (x * x) % m;
    p >>= 1;
  }
  return res;
}
long double ModLog(long double base, long double x) {
  return (logl(x) / logl(base));
}
int main() {
  int l = D(), r = D();
  bool found = false;
  for (int i = l; i <= r; ++i) {
    int curr = i;
    set<int> st;
    bool f = true;
    while (curr) {
      int d = curr % 10;
      if (st.count(d)) f = false;
      st.insert(d);
      curr /= 10;
    }
    if (f) {
      found = true;
      printf("%d\n", i);
      break;
    }
  }
  if (!found) puts("-1");
}
