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