#include <bits/stdc++.h>
using namespace std;
template <typename... T>
void read(T&... args) {
  ((cin >> args), ...);
}
long long int modularExponentiation(long long int x, long long int n,
                                    long long int M) {
  if (n == 0)
    return 1;
  else if (n % 2 == 0)
    return modularExponentiation((x * x) % M, n / 2, M);
  return (x * modularExponentiation((x * x) % M, (n - 1) / 2, M)) % M;
}
template <class T>
T power(T n, T p) {
  if (p == 0)
    return 1;
  else
    return power(n, p - 1) * n;
}
void solve() {
  int l, r;
  cin >> l >> r;
  for (int i = l; i < r + 1; i++) {
    int x = i;
    int occ[10] = {0};
    while (x) {
      occ[x % 10]++;
      x /= 10;
    }
    bool ok = true;
    for (int j = 0; j < 10; j++) {
      if (occ[j] > 1) ok = false;
    }
    if (ok) {
      cout << i;
      return;
    }
  }
  cout << "-1";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
}
