#include <bits/stdc++.h>
using namespace std;
int main() {
  int l, r, i, j, d, tp;
  cin >> l >> r;
  bool f;
  for (i = l; i <= r; i++) {
    tp = i;
    int arr[10];
    for (j = 0; j < 10; j++) arr[j] = 0;
    while (tp > 0) {
      d = tp % 10;
      tp = tp / 10;
      arr[d]++;
    }
    f = true;
    for (j = 0; j < 10; j++) {
      if (arr[j] <= 1)
        f = true;
      else {
        f = false;
        break;
      }
    }
    if (!f)
      f = false;
    else {
      cout << i;
      f = true;
      break;
    }
  }
  if (!f) cout << "-1";
  return 0;
}
