#include <bits/stdc++.h>
using namespace std;
const long long MAX = 1e5 + 3;
const long long mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  while (t--) {
    long long x, y, c, r, j;
    cin >> x >> y;
    map<long long, long long> m;
    for (long long i = x; i <= y; i++) {
      m.clear();
      j = i;
      c = 0;
      while (j != 0) {
        r = j % 10;
        if (m[r] == 0) {
          m[r]++;
        } else {
          c = -1;
          break;
        }
        j = j / 10;
      }
      if (c == 0) {
        cout << i;
        return 0;
      }
    }
    cout << "-1";
  }
}
