#include <bits/stdc++.h>
using namespace std;
int dif(int a) {
  vector<int> p;
  int i;
  int tag = 0;
  while (a != 0) {
    p.push_back(a % 10);
    a = a / 10;
  }
  sort(p.begin(), p.end());
  for (i = 1; i < p.size(); i++) {
    if (p[i] == p[i - 1]) {
      return 0;
      tag = 1;
      break;
    }
  }
  if (tag == 0) return 1;
}
int main() {
  int l, r, i;
  cin >> l >> r;
  for (i = l; i <= r; i++) {
    if (dif(i)) {
      cout << i;
      break;
    }
  }
  if (i == r + 1) cout << -1;
}
