#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;
    int a[7] = {0};
    int q = 0;
    int judge = 0;
    while (temp) {
      a[q++] = temp % 10;
      temp = temp / 10;
    }
    sort(a, a + q);
    for (int j = 1; j < q; j++) {
      if (a[j] == a[j - 1]) {
        judge = 1;
        break;
      }
    }
    if (judge) {
      continue;
    } else {
      cout << i << endl;
      return 0;
    }
  }
  cout << "-1" << endl;
  return 0;
}
