#include <bits/stdc++.h>
using namespace std;
const long double pi = 3.14159265358979323846;
const long long mod = 1000000007;
bool check(long long x) {
  if (x == 0) return true;
  long long d[10] = {0};
  while (x) {
    long long lsb = x % 10;
    if (d[lsb]) {
      return false;
    }
    d[lsb] = 1;
    x /= 10;
  }
  return true;
}
int main() {
  { ios_base::sync_with_stdio(false); }
  {
    cin.tie(NULL);
    cout.tie(NULL);
  };
  long long left, right;
  cin >> left >> right;
  long long ans(-1);
  for (long long x = left; x <= right; x++) {
    if (check(x)) {
      ans = x;
      break;
    }
  }
  cout << ans << "\n";
  return 0;
}
