#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int l, r;
  cin >> l >> r;
  for (int i = l; i <= r; i++) {
    int A[10];
    memset(A, 0, sizeof(A));
    long long int x = i;
    int flag = 0;
    while (x) {
      int d = x % 10;
      if (A[d]) flag = 1;
      A[d] = 1;
      x /= 10;
    }
    if (flag == 0) {
      cout << i << endl;
      return;
    }
  }
  cout << -1 << endl;
}
int main() {
  long long int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
