#include <bits/stdc++.h>
using namespace std;
bool check(int n) {
  bool dig[10] = {false};
  bool flag = true;
  int cur = -1;
  while (n && flag) {
    cur = n % 10;
    n /= 10;
    if (dig[cur]) {
      flag = false;
      break;
    } else
      dig[cur] = true;
  }
  return flag;
}
int main() {
  int l, r;
  cin >> l >> r;
  bool found = false;
  for (int i = l; found == false && i <= r; i++) {
    if (check(i)) {
      found = true;
      cout << i << endl;
    }
  }
  if (found == false) cout << "-1" << endl;
  return 0;
}
