#include <bits/stdc++.h>
using namespace std;
int main() {
  int l, r, t, ans = 0;
  cin >> l >> r;
  if (l > r) {
    t = r;
    r = l;
    l = t;
  }
  for (int i = l; i <= r; i++) {
    map<int, int> q;
    int k, l = 0, flage = 0;
    int b = i;
    while (b) {
      int k = b % 10;
      if (q[k] == 1) {
        flage = 1;
        break;
      } else
        q[k] = 1;
      b = b / 10;
    }
    if (flage == 0) {
      cout << i << endl;
      ans = 1;
      break;
    }
  }
  if (ans == 0) cout << "-1" << endl;
  return 0;
}
