program name
    implicit none
    character(26):: s
    integer(4):: ls,i,mic, min_
    integer(4),allocatable:: si(:)
    logical:: is_use(26), f

    read*, s
    ls = len_trim(s)
    allocate(si(ls))

    do i=1,ls
        si(i) = ichar(s(i:i)) - ichar('a') + 1
    end do

    is_use(:) = .false.

    do i=1,ls
        is_use(si(i)) = .true.
    end do

    mic=10001
    do i=1,26
        if (.not. is_use(i))  mic=min(mic,i)
    end do
    f=.false.
    min_=1000001
    if (mic==10001) then
        do i=ls,2,-1
            if (si(i) == 27-i) cycle
            ! print*, minval(si(i:)), ichar(s(i-1:i-1))-ichar('a')+1
            if (minval(si(i:)) <= ichar(s(i-1:i-1))-ichar('a')+1) cycle
            s(i-1:i-1) = char(minval(si(i:))+ichar('a')-1)
            print*, s(1:i-1)
            stop
        end do
        print*, -1
        stop
    end if



    s(ls+1:ls+1) = char(mic+ichar('a')-1)

    print*, trim(s)


end program name