#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int i, j, l, r;
  cin >> l >> r;
  for (i = l; i <= r; i++) {
    int count[10] = {0};
    j = i;
    while (j > 0) {
      count[j % 10]++;
      j /= 10;
    }
    for (j = 0; j < 10; j++) {
      if (count[j] > 1) {
        break;
      }
    }
    if (j == 10) {
      break;
    }
  }
  if (i <= r) {
    cout << i << "\n";
  } else {
    cout << "-1"
         << "\n";
  }
  return 0;
}
