#include <bits/stdc++.h>
using namespace std;
int valid(int x) {
  int flag[15] = {0}, y;
  if (x / 10 == 0) return 1;
  while (x != 0) {
    y = x % 10;
    if (flag[y] == 0)
      flag[y] = 1;
    else
      return 0;
    x = x / 10;
  }
  return 1;
}
int main() {
  int l, r, i;
  cin >> l >> r;
  for (i = l; i <= r; i++) {
    if (valid(i)) {
      cout << i << endl;
      return 0;
    }
  }
  cout << "-1\n";
  return 0;
}
