#include <bits/stdc++.h>
using namespace std;
int main() {
  int l, r, cnt[10], i;
  bool found;
  cin >> l >> r;
  for (i = l; i <= r; i++) {
    int num = i;
    memset(cnt, 0, sizeof(cnt));
    while (num != 0) {
      int d = num % 10;
      cnt[d]++;
      num /= 10;
    }
    found = true;
    for (int j = 0; j < 10; j++) {
      if (cnt[j] > 1) {
        found = false;
        break;
      }
    }
    if (found) break;
  }
  cout << (found ? i : -1) << endl;
  return 0;
}
