#include <bits/stdc++.h>
using namespace std;
long long input() {
  long long x = 0, f = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') f |= ch == '-', ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return f ? -x : x;
}
int l, r;
int dig[10];
bool check(int x) {
  bool f = 1;
  memset(dig, 0, sizeof dig);
  while (x) {
    dig[x % 10]++;
    if (dig[x % 10] >= 2) f = 0;
    x /= 10;
  }
  return f;
}
int main() {
  l = input(), r = input();
  for (int i = l; i <= r; i++) {
    if (check(i)) {
      printf("%d\n", i);
      return 0;
    }
  }
  printf("-1\n");
}
