let () =
  let find_opt f t =
    let rec loop = function
      | [] -> None
      | x :: l -> if f x then Some x else loop l
    in
    loop t
  in

  let a = Scanf.scanf "%s\n" (fun a -> a) in
  let input_char_list = BatString.to_list a in
  let all_chars = ['a';'b';'c';'d';'e';'f';'g';'h';'i';'j';'k';'l';'m';'n';'o';'p';'q';'r';'s';'t';'u';'v';'w';'x';'y';'z';] in

  let next_char c =
    let code = BatChar.code c in
    BatChar.chr (code + 1)
  in


  let hoge input_chars all_chars =
    let rec aux l = match l with
      | [] -> []
      | hd :: tl ->
        (
          match (find_opt (fun x -> x = hd) input_chars) with
            Some x -> aux tl
          | None -> [hd]
        )
    in
    aux all_chars
  in

  let test =
    match (hoge input_char_list all_chars) with
    | [] ->
      (
        if a = "zyxwvutsrqponmlkjihgfedcba"
        then "-1"
        else
          let rec fuga l last = match l with
            | [] -> []
            | aa :: bb :: cc ->
              if ((BatChar.code last) < (BatChar.code bb))
              then
                fuga (bb :: cc) last
              else
                BatList.append [(next_char bb)] (cc)
          in
          let last = List.hd (List.rev input_char_list) in
          fuga (List.rev input_char_list) last |>
          List.rev |>
          BatString.of_list

      )

    | [hd] -> BatList.append input_char_list [hd] |> BatString.of_list
  in

  print_endline test
