#include <bits/stdc++.h>
using namespace std;
int l, r;
bool used[20];
bool judge(int x) {
  memset(used, 0, sizeof used);
  int y;
  while (x) {
    if (used[x % 10]) return false;
    used[x % 10] = 1;
    x /= 10;
  }
  return true;
}
int main() {
  cin >> l >> r;
  for (int i = l; i <= r; i++) {
    if (judge(i)) {
      cout << i << endl;
      return 0;
    }
  }
  puts("-1");
  return 0;
}
