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