#include <bits/stdc++.h>
using namespace std;
int a(int i) {
  if (i / 10 == 0) {
    return 0;
  } else {
    vector<int> v;
    int t = 0;
    while (i != 0) {
      int b = i % 10;
      i /= 10;
      vector<int>::iterator it = find(v.begin(), v.end(), b);
      if (it == v.end()) {
        v.push_back(b);
      } else {
        t = 1;
        break;
      }
    }
    if (t == 0) {
      return 0;
    } else {
      return 1;
    }
  }
}
int main() {
  int l, r;
  cin >> l >> r;
  int b = 0;
  int i;
  for (i = l; i <= r; i++) {
    if (a(i) == 0) {
      b = 1;
      break;
    }
  }
  if (b == 1) {
    cout << i;
  } else {
    cout << -1;
  }
}
