#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int l, r;
  cin >> l >> r;
  bool res = true;
  for (int i = l; i <= r; ++i) {
    vector<int> v(10, 0);
    int n = i, c;
    while (n != 0) {
      int r = n % 10;
      n /= 10;
      v[r]++;
    }
    for (int i = 0; i < 10; ++i) {
      if (v[i] > 1) {
        c = 0;
        break;
      } else
        c = 1;
    }
    if (c == 1) {
      res = false;
      cout << i << endl;
      break;
    }
  }
  if (res) cout << "-1" << endl;
  return 0;
}
