#include <bits/stdc++.h>
using namespace std;
int main() {
  long long l, r, x, i, a, b, j;
  int c = 0, flag = 0;
  cin >> l >> r;
  for (i = l; i <= r; i++) {
    x = i;
    int f[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    while (x != 0) {
      f[x % 10]++;
      x /= 10;
    }
    for (j = 0; j < 10; j++) {
      if (f[j] > 1) {
        flag = 1;
        break;
      }
    }
    if (flag == 0) {
      cout << i;
      return 0;
    }
    flag = 0;
  }
  cout << -1;
  return 0;
}
