#include <bits/stdc++.h>
using namespace std;
bool vis[10];
bool ok(int n) {
  while (n) {
    int r = n % 10;
    if (vis[r])
      return false;
    else
      vis[r] = 1;
    n /= 10;
  }
  return true;
}
int main() {
  int l, r;
  scanf("%d%d", &l, &r);
  for (int i = l; i <= r; ++i) {
    memset(vis, 0, sizeof(vis));
    if (ok(i)) return cout << i, 0;
  }
  cout << -1;
  return 0;
}
