#include <bits/stdc++.h>
using namespace std;
vector<char> vec[101];
int main() {
  int l, r;
  unordered_map<int, int> m;
  cin >> l >> r;
  for (int i = l; i <= r; i++) {
    int k = i, flag = 0;
    while (k > 0) {
      int d = k % 10;
      m[d]++;
      k /= 10;
    }
    for (auto it = m.begin(); it != m.end(); it++)
      if (it->second > 1) flag = 1;
    if (flag == 0) {
      cout << i;
      return 0;
    }
    m.clear();
  }
  cout << -1;
  return 0;
}
