#include <bits/stdc++.h>
using namespace std;
int main() {
  int l, r, num, flag = 0;
  cin >> l >> r;
  int a[10] = {0};
  int g = 0;
  for (int i = l; i <= r;) {
    num = i;
    for (int i = 0; i < 10; i++) a[i] = 0;
    while (num) {
      a[num % 10]++;
      num /= 10;
    }
    int flag = 0;
    for (int i = 0; i < 10; i++) {
      if (a[i] >= 2) flag = 1;
    }
    if (flag == 1)
      i++;
    else {
      cout << i;
      g = 1;
      break;
    }
  }
  if (g == 0) cout << -1;
}
