#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
bool ok(int x) {
  map<int, int> cnt;
  while (x) {
    int r = x % 10;
    if (cnt[r] == 1) return false;
    cnt[r]++;
    x /= 10;
  }
  return true;
}
int main() {
  int l, r;
  cin >> l >> r;
  for (int i = l; i <= r; i++)
    if (ok(i)) return cout << i, 0;
  cout << -1;
}
