#include <bits/stdc++.h>
using namespace std;
int v[12];
bool ju(int x) {
  memset(v, 0, sizeof(v));
  int cnt = 0;
  while (x) {
    v[x % 10] = 1;
    x /= 10;
    cnt++;
  }
  int now = 0;
  for (int i = 0; i < 9; i++) {
    if (v[i]) now++;
  }
  if (cnt == now)
    return true;
  else
    return false;
}
int main() {
  int a, b;
  scanf("%d%d", &a, &b);
  for (int i = a; i <= b; i++) {
    if (ju(i)) {
      printf("%d\n", i);
      return 0;
    }
  }
  printf("-1\n");
  return 0;
}
