#include <bits/stdc++.h>
int main() {
  int x, y;
  std::cin >> x >> y;
  for (int i = x; i <= y; i++) {
    int temp_i = i;
    bool judge[10] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
    int cnt = 0, count = 0;
    bool temp_b = true;
    while (temp_i) {
      count++;
      int temp = temp_i % 10;
      if (judge[temp]) {
        judge[temp] = false;
      } else {
        temp_b = false;
        break;
      }
      temp_i /= 10;
    }
    if (temp_b) {
      std::cout << i << std::endl;
      return 0;
    }
  }
  std::cout << -1;
}
