#include <bits/stdc++.h>
using namespace std;
int length(int i) {
  int c = 0;
  while (i) {
    c++;
    i /= 10;
  }
  return c;
}
bool good(int i) {
  unordered_set<char> d;
  int len = length(i);
  while (i) {
    d.insert(i % 10);
    i /= 10;
  }
  return (d.size() < len) ? false : true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int l, r;
  cin >> l >> r;
  for (int i = l; i <= r; i++) {
    if (good(i)) {
      cout << i << "\n";
      return 0;
    }
  }
  cout << "-1\n";
}
