#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  for (int i = a; i <= b; i++) {
    string s = to_string(i);
    int dc[10] = {0};
    bool b = true;
    for (char x : s) {
      if (dc[x - '0'] > 0) {
        b = false;
        break;
      } else {
        dc[x - '0']++;
      }
    }
    if (b) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}
