#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  int flag = 0;
  for (int i = a; i <= b; i++) {
    int arr[10] = {0};
    int x = i;
    while (x != 0) {
      arr[x % 10] += 1;
      x /= 10;
    }
    int j;
    for (j = 0; j < 10; j++) {
      if (arr[j] > 1) {
        break;
      }
    }
    if (j == 10) {
      flag = 1;
      cout << i << endl;
      break;
    }
  }
  if (flag == 0) {
    cout << -1 << endl;
  }
}
