#include <bits/stdc++.h>
using namespace std;
long double PI = acosl(-1);
bool myfunc(int a, int b) { return (a > b); }
long long int fact(long long int n) {
  if (n == 0 || n == 1)
    return 1;
  else
    return n * fact(n - 1);
}
int z[10] = {0};
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int x, y;
  cin >> x >> y;
  int temp = x, cnt;
  for (int i = x; i <= y; i++) {
    memset(z, -1, sizeof(z));
    cnt = 0;
    int tem = i;
    while (tem) {
      if (z[tem % 10] == -1) z[tem % 10] = 0;
      tem /= 10;
      cnt++;
    }
    if (count(z, z + 10, 0) >= cnt) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
