#include <bits/stdc++.h>
using namespace std;
int l, r, dist[15];
int find(int s) {
  while (s > 0) {
    int lin = s % 10;
    if (dist[lin] == 0) {
      dist[lin] = 1;
    } else {
      return 0;
    }
    s /= 10;
  }
  return 1;
}
int main() {
  scanf("%d%d", &l, &r);
  for (int i = l; i <= r; i++) {
    memset(dist, 0, sizeof(dist));
    if (find(i) == 1) {
      printf("%d\n", i);
      return 0;
    }
  }
  printf("-1\n");
  return 0;
}
