#include <bits/stdc++.h>
using namespace std;
long long mark[10];
int main() {
  long long l, r;
  cin >> l >> r;
  for (long long i = l; i <= r; i++) {
    long long temp = i;
    while (temp) {
      long long indx = temp % 10;
      if (mark[indx] == 0)
        mark[indx] = 1;
      else
        break;
      temp = temp / 10;
    }
    if (!temp) {
      cout << i << endl;
      return 0;
    }
    for (long long j = 0; j < 10; j++) mark[j] = 0;
  }
  cout << -1 << endl;
  return 0;
}
