#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int l, r, check = 0;
  cin >> l >> r;
  for (long long int i = l; i <= r; i++) {
    long long int num = i;
    vector<bool> visited(100001, false);
    while (num) {
      if (visited[num % 10]) break;
      visited[num % 10] = true;
      num = num / 10;
    }
    if (num == 0) {
      cout << i << "\n";
      check = 1;
      break;
    }
  }
  if (check == 0) {
    cout << -1 << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
