#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
const int Mod = 1e9 + 7;
int n;
int a, b;
int v[100];
bool f(int x) {
  memset(v, 0, sizeof(v));
  while (x) {
    int a = x % 10;
    if (v[a] >= 1) return false;
    v[a] = 1;
    x /= 10;
  }
  return true;
}
int main() {
  cin >> a >> b;
  for (int i = a; i <= b; i++) {
    if (f(i)) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
