program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: i,n
    character(26):: s
    logical:: cuse(ichar('a'):ichar('z'))

    read*, s
    n = len_trim(s)
    cuse(:) = .false.
    do i=1,n
        cuse(ichar(s(i:i)))=.true.
    end do

    do i=ichar('a'),ichar('z')
        if (.not.cuse(i)) then
            print'(a)', trim(s)//char(i)
            stop
        end if
    end do

    do i=n-1,1,-1
        if (s(i:i) < s(i+1:i+1)) then
            print'(a)', trim(s(:i-1))//change(s(i:))
            stop
        end if
    end do

    print'(i0)', -1

contains
    function change(str) result(ret)
        character(*):: str
        character(1),allocatable:: ret
        integer(int32):: i,ln

        ln = len_trim(str)
        do i=ln,2,-1
            if (str(i:i) > str(1:1))then
                ret=str(i:i)
                return
            end if
        end do
    end function
end program name