#include <bits/stdc++.h>
using namespace std;
bool allDifferent(int n) {
  set<int> digits;
  while (n != 0) {
    int digit = n % 10;
    if (digits.count(digit) != 0) {
      return (false);
    }
    digits.insert(digit);
    n = (n - digit) / 10;
  }
  return (true);
}
int main() {
  int l, r, x;
  cin >> l >> r;
  for (int i = l; i <= r; i++) {
    if (allDifferent(i) == true) {
      cout << i;
      return 0;
    }
  }
  cout << -1;
  return 0;
}
