#include <bits/stdc++.h>
using namespace std;
set<int> m;
using namespace std;
bool check(int a) {
  m.erase(m.begin(), m.end());
  int i = 0;
  while (a > 0) {
    int re = a % 10;
    m.insert(re);
    a /= 10;
    i++;
  }
  if (m.size() == i) {
    return true;
  } else
    return false;
}
int main() {
  int l, r, flag = 0;
  long long int ans = 0;
  cin >> l >> r;
  for (int i = l; i <= r; i++) {
    if (check(i) == true) {
      ans = i;
      flag = 1;
      break;
    }
  }
  if (flag == 1) {
    cout << ans << endl;
  } else
    cout << "-1" << endl;
}
