#include <bits/stdc++.h>
using namespace std;
bool valid(int x) {
  bool seen[10];
  for (int i = 0; i < 10; ++i) {
    seen[i] = false;
  }
  while (x) {
    int digit = x % 10;
    x /= 10;
    if (seen[digit]) {
      return false;
    }
    seen[digit] = true;
  }
  return true;
}
int main() {
  int l, r;
  cin >> l >> r;
  for (int i = l; i <= r; ++i) {
    if (valid(i)) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
