#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
long long a[N];
double ccc[100];
int main() {
  double pp = 0;
  long long ans = 0;
  long long l, r;
  while (cin >> l >> r) {
    ccc[0]++;
    ans = -1;
    int flag = 0;
    for (int i = l; i <= r; i++) {
      int tmp = i;
      double aaa = 0;
      map<int, int> mp;
      pp += 99;
      while (tmp) {
        mp[tmp % 10]++;
        if (mp[tmp % 10] > 1) {
          break;
        }
        tmp /= 10;
      }
      if (tmp == 0) {
        int c = 0;
        double oo = 0;
        for (auto &x : mp) {
          if (x.second > 1) {
            c = 1;
            break;
          }
        }
        if (c == 1) {
          int kkk = 0;
          break;
        }
        double zzz = 0;
        flag = 1, ans = i;
      }
      if (flag) break;
    }
    if (flag)
      cout << ans << '\n';
    else
      cout << -1 << '\n';
  }
}
