#include <bits/stdc++.h>
using namespace std;
int g2[1002][1002];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = n; i <= m; i++) {
    int ind = 0;
    string s = to_string(i);
    string m = s;
    sort(s.begin(), s.end());
    for (int p = 1; p < s.size(); p++)
      if (s[p] == s[p - 1]) {
        ind = 1;
        break;
      }
    if (ind == 1) continue;
    cout << m;
    return 0;
  }
  cout << -1;
  return 0;
}
