#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, e, p, i, n, c = 0;
  cin >> a >> b;
  for (i = a; i <= b; i++) {
    p = i;
    set<int> s;
    c = e = 0;
    while (p != 0) {
      n = p % 10;
      s.insert(n);
      c++;
      p /= 10;
    }
    if (s.size() == c) {
      e = 1;
      break;
    }
  }
  if (e)
    cout << i << endl;
  else
    cout << "-1" << endl;
  return 0;
}
