#include <bits/stdc++.h>
using namespace std;
int main() {
  bool check = false;
  int left, right;
  cin >> left >> right;
  for (int i = left; i <= right; i++) {
    int num = i;
    bool ch[10] = {false};
    while (num > 0) {
      if (ch[num % 10]) break;
      ch[num % 10] = true;
      num /= 10;
    }
    if (num == 0) {
      cout << i;
      check = true;
      break;
    }
  }
  if (!check) cout << "-1";
  return 0;
}
