#include <bits/stdc++.h>
using namespace std;
int main() {
  int l, r;
  cin >> l >> r;
  for (int i = l; i <= r; ++i) {
    int d[10] = {};
    int c = i;
    bool ok = true;
    while (c) {
      if (d[c % 10]) {
        ok = false;
        break;
      }
      d[c % 10] += 1;
      c /= 10;
    }
    if (ok) {
      cout << i << '\n';
      return 0;
    }
  }
  cout << "-1\n";
}
