#include <bits/stdc++.h>
using namespace std;
bool check(long long n) {
  long long a[10] = {0};
  while (n) {
    a[n % 10]++;
    n /= 10;
  }
  for (long long i = 0; i < 10; i++) {
    if (a[i] > 1) {
      return false;
    }
  }
  return true;
}
signed main() {
  long long l, r;
  cin >> l >> r;
  for (long long i = l; i <= r; i++) {
    if (check(i)) {
      return cout << i, 0;
    }
  }
  cout << -1;
}
