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

    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

    if (mic==10001) then
        ri = 1000
        do i=ls,2,-1
            if (s(i-1:i-1) < s(i:i)) then
                ri = i
                exit
            end if
        end do

        if(ri == 1000) then
            print*, -1
            stop
        end if
        mins='z'
        do i=ri,ls
            if (s(ri-1:ri-1) >= s(i:i)) cycle
            mins = min(s(i:i),mins)
        end do
        print*, s(1:ri-2) // mins
        stop
    end if



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

    print*, trim(s)


end program name