Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim s As String = NextString()
        Dim t(s.Length - 1) As Char
        For i As Integer = 0 To UBound(t)
            t(i) = s(i)
        Next

        For v As Integer = Asc("a"c) To Asc("z"c)
            If Not s.Contains(Chr(v) & "") Then
                WriteLine(s & Chr(v))
                Return
            End If
        Next

        If Not NexstPermutation(t) Then
            WriteLine(-1)
        Else
            Dim i As Integer = 0
            Do While s(i) = t(i)
                Write(s(i))
                i += 1
            Loop
            WriteLine(t(i))
        End If

    End Sub

    Function NexstPermutation(t As Char()) As Boolean
        Dim n As Integer = Len(t)
        Dim i As Integer = n - 2

        Do While i >= 0 AndAlso t(i) >= t(i + 1)
            i -= 1
        Loop
        If i < 0 Then Return False

        Dim j As Integer = i + 1
        Do While j < n AndAlso t(j) > t(i)
            j += 1
        Loop
        j -= 1
        Dim tmp As Char = t(i)
        t(i) = t(j)
        t(j) = tmp

        Dim left As Integer = i + 1
        Dim right As Integer = n - 1

        Do While left < right
            tmp = t(left)
            t(left) = t(right)
            t(right) = tmp

            left += 1
            right -= 1
        Loop

        Return True
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function
End Module
