#include <bits/stdc++.h>
int main(void) {
  int l, r, x, a[6], c, i = 0, k = 0, j, flag = 1;
  scanf("%d %d", &l, &r);
  for (x = l; x <= r; x++) {
    k = 0;
    flag = 1;
    c = x;
    i = 0;
    while (c != 0) {
      a[i] = c % 10;
      c = c / 10;
      i++;
      k++;
    }
    for (i = 0; i < k - 1; i++) {
      for (j = i + 1; j < k; j++)
        if (a[i] == a[j]) {
          flag = 0;
          break;
        }
      if (flag == 0) break;
    }
    if (flag) {
      printf("%d", x);
      break;
    }
  }
  if (flag == 0) printf("-1");
}
