#include <bits/stdc++.h>
using namespace std;
int main() {
  long long x, y;
  cin >> x >> y;
  for (int i = x; i <= y; i++) {
    int freq[10] = {0};
    int m = i;
    while (m) {
      int x = m % 10;
      if (freq[x] >= 1) break;
      freq[x] += 1;
      m /= 10;
    }
    if (m == 0) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}
