#include <bits/stdc++.h>
using namespace std;
bool fun(int x) {
  string s;
  s = to_string(x);
  bool arr[10];
  for (int i = 0; i <= 9; i++) {
    arr[i] = false;
  }
  for (int i = 0; i < s.size(); i++) {
    if (arr[s[i] - '0'] == true) {
      return false;
    } else {
      arr[s[i] - '0'] = true;
    }
  }
  return true;
}
int main() {
  int a;
  int b;
  cin >> a >> b;
  bool flag = false;
  for (int i = a; i <= b; i++) {
    if (fun(i) == true) {
      cout << i << "\n";
      flag = true;
      break;
    }
  }
  if (flag != true) {
    cout << "-1"
         << "\n";
  }
  return 0;
}
