#include <bits/stdc++.h>
using namespace std;
bool check(int v) {
  bool t[10] = {0};
  while (v) {
    int p = v % 10;
    if (t[p]) {
      return false;
    }
    t[p] = true;
    v /= 10;
  }
  return true;
}
int main() {
  int a, b, ta;
  cin >> a >> b;
  for (; a <= b; ++a) {
    if (check(a)) {
      cout << a;
      return 0;
    }
  }
  cout << -1;
  return 0;
}
