#include <bits/stdc++.h>
using namespace std;
int main() {
  int l, r;
  cin >> l >> r;
  for (int i = l; i <= r; i++) {
    int temp = i;
    bool dif = true;
    vector<int> num;
    while (temp > 0) {
      int digit = temp % 10;
      temp /= 10;
      num.push_back(digit);
    }
    for (int j = 0; j < num.size(); j++) {
      for (int k = j + 1; k < num.size(); k++) {
        if (num[j] == num[k]) {
          dif = false;
          break;
        }
      }
    }
    if (dif) {
      cout << i << endl;
      break;
    }
    if (i == r) cout << "-1" << endl;
  }
  return 0;
}
